Subject: Computer Programming & Application Lab

Subject: Computer Programming & Application Lab

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)

  1. 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.

  1. Using Microsoft PowerPoint prepare a seminar presentation. Use design template for slides.
  1. Write a program to convert Fahrenheit temperature to Celsius

Fahrenheit=1.8*Celsius+32

  1. 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

n=96875

digit_1=n%10=96875%10=5

n=n/10=96875/10=9687

digit_2=n%10=9687%10=7

n=n/10=9687/10=968

digit_3=n%10=968%10=8

n=n/10=968/10=96

digit_4=n%10=96%10=6

n=n/10=96/10=9

digit_5=9

Sum=digit_1+digit_2+digit_3+digit_4+digit_5

  1. Given a 5 digit integer write a c++ program to print it in reverse order

Logic is same as the above problem

digit=n%10

rev_dgit=rev_digit+digit*10

n=n/10

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

Input= Enter the radius of the circle

Output= Print area and perimeter

  1. 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.
  1. Using conditional statement write a program to pick the largest of 3 numbers.
  1. 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

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.

  1. Write a class person that would contain basic information such as name, birth date and address. Derive class student from person.
  1. 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
  1. Write a program in C++ to add two complex numbers using friend function
  1. 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 balance

b)Display the balance

c)Compute and deposit interest

d)Permit withdrawal and update the balance

e)Check for the minimum balance. Impose penalty if necessary and update the balance. Use member function to initialize the objects

  1. 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
  1. 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)

  1. 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 shape

class Rectangle : public shape {

Private:

double height, width

Public:

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

}