swlab for software

5
Course Manual Class S3MN Subject: Computer Programming & Application Lab Total Contact Hours: 24 C++ Exercises 1. Create worksheet as shown below using the calculation method shown in the table Computer Parts SNO ITEM COST TAX PROFIT SALE DISCNT FINAL PROFIT NAME PRICE 4% 25% PRICE 10% PIRICE 1 Mouse 100 2 Printer 2000 3 Hard disc 3000 4 Scanner 2500 5 Ram 1500 6 Keyboard 750 7 Scroll Mouse 500 8 Monitor 6000 9 Modem 1250 10 Computer table 2599 Calculation Method Final price= Sale Price- Discount Profit= Final price-(Cost Price-Tax) 2. Create a database called student in Microsoft Access and create a table having fields student id, student name, marks for different subjects. Set student id as primary key. Insert records using Microsoft Access.

Transcript of swlab for software

Page 1: swlab for software

Course ManualClass S3MN

Subject: Computer Programming & Application LabTotal Contact Hours: 24

C++ Exercises

1. Create worksheet as shown below using the calculation method shown in the table

                         Computer Parts      SNO ITEM COST TAX PROFIT SALE DISCNT FINAL PROFIT  NAME PRICE 4% 25% PRICE 10% PIRICE  

1 Mouse 100            2 Printer 2000            3 Hard disc 3000            4 Scanner 2500            5 Ram 1500            6 Keyboard 750            7 Scroll Mouse 500            8 Monitor 6000            9 Modem 1250            

10Computer table 2599            

Calculation MethodFinal price= Sale Price- DiscountProfit= Final price-(Cost Price-Tax)

2. Create a database called student in Microsoft Access and create a table having fields student id, student name, marks for different subjects. Set student id as primary key. Insert records using Microsoft Access.

3. Using Microsoft PowerPoint prepare a seminar presentation. Use design template for slides.

4. Write a program to convert Fahrenheit temperature to Celsius

Fahrenheit=1.8*Celsius+32

5. A five digit positive integer is given. It is required to find the sum of individual digits. For example if the given number is 96875 the required sum is 9+6+8+7+5=35. Write a C++ program for the above problem

Page 2: swlab for software

n=96875digit_1=n%10=96875%10=5n=n/10=96875/10=9687

digit_2=n%10=9687%10=7n=n/10=9687/10=968

digit_3=n%10=968%10=8n=n/10=968/10=96

digit_4=n%10=96%10=6n=n/10=96/10=9

digit_5=9

Sum=digit_1+digit_2+digit_3+digit_4+digit_5

6. Given a 5 digit integer write a c++ program to print it in reverse orderLogic is same as the above problemdigit=n%10rev_dgit=rev_digit+digit*10n=n/10

7. Write a C++ program to read the radius of the circle and compute its area and perimeter.

Input= Enter the radius of the circleOutput= Print area and perimeter

8. Write a program to find the rupee equivalent of US dollars using the exchange rate to nearest 50 paisa. For example if x=42.25 and exchange rate is Rs.31.16 pr dollar the answer should be Rupees 1317 paisa 50.

9. Using conditional statement write a program to pick the largest of 3 numbers.

10. Obtain decision tables for simulating an automatic stamp wending machine with the following specifications.

It should dispense 1, 2 and 5 rupee stamps

It should accept 1, 2, 5 rupee coins

It can accept not more than one coin for each transaction

Page 3: swlab for software

If more than one coin of the same denomination is to be returned as change after dispensing the stamp, the machine cannot do it. Instead the coin should be returned and no change signal turned on.

Write a program to simulate the machine. The input of the program would be amount tendered and stamp requested.The output of the program should be whether the stamp is dispensed or not, the value of the stamp dispensed, the denomination of the coin returned (if any) and no change signal if no change is returned and no stamp if the stamp is not available.

11. Write a class person that would contain basic information such as name, birth date and address. Derive class student from person.

12. Write a class triangle that inherits from shape. It needs to have a constructer and destructor function to get the relevant information of triangle. Also it should have its own area( ) member function

13. Write a program in C++ to add two complex numbers using friend function

14. A bank account consists of two kinds of accounts for customers are called as savings account and the other as current account. The saving account provides compound interest and withdrawal facility but no cheque book facility. The current account provides cheque book facility but no interest. Current account holders should also maintain a minimum balance and if the balance falls below this level a service charge is imposed. Create a class account that stores customer name, account number and type of account. from this derive the classes current account and savings account to make them more specific to their requirements

a) Accept deposit from the customer and update the balanceb) Display the balancec) Compute and deposit interestd) Permit withdrawal and update the balancee) Check for the minimum balance. Impose penalty if necessary and update the balance. Use

member function to initialize the objects

15. Using C++ write a program to accept rollno, mark1, mark2, mark3 and save it to a file. Whenever the user enters the roll number , the details of the students should be displayed

16. Overload the operator * in class string. Find the expression s*k that will be a string which means k copies the string s

String operator*(int n)

Page 4: swlab for software

17. Create a base class shape which uses a virtual function called area. Derive two classes triangle and rectangle from the class shape and find the area using the concept Polymorphism.

class Shape { Public:

Virtual double area ( ) =0;};

Derive a class from shapeclass Rectangle : public shape {

Private: double height, width

Public:double area( ) { return ( height* width)}

}