Learn C++ beginer programs

July 6, 2009

Write a program to store consumer number and number of calls and calculate telephone bill accordin to condition

Filed under: bill,cin,cout,else if,if,if else — snehilkhanor @ 2:27 am
Take Customer number and no. of calls from user.
Calculate Bill as follows..
If number of calls <=100 : Free
Number of calls >=200 <=300 : 1.40 per call on over 100
Number of calls >=300 <=400 : 140+1.60 per call on over 200
Number of calls >=300 <=400 : 300+1.80 per call on over 300
Number of calls >=400 : 480+2.10 per call on over 400
And Fixed monthly rental: RS 100
And generate bill.
Select To use this code as it is.. select and copy paste this code into code.cpp file :)
  1. #include <iostream.h>
  2. #include <conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. float id,qty,tot,amt;
  7. cout<<”Enter Customer No.: “;
  8. cin>>id;
  9. cout<<”Please Enter No. of Calls: “;
  10. cin>>qty;
  11. if(qty<=100)
  12. amt=0;
  13. else if(qty>100&&qty<=200)
  14. amt=1.40*(qty-100);
  15. else if(qty>200&&qty<=300)
  16. amt=140+1.60*(qty-200);
  17. else if(qty>300&&qty<=400)
  18. amt=300+1.80*(qty-300);
  19. else
  20. amt=480+2.10*(qty-400);
  21. tot=100+amt;
  22. cout<<”\n\n\nCustomer NO.: “<<id<<”\nNo. of Calls: “<<qty<<”\nMonthly Rental:
  23. INR 100\nTotal amt: INR “<<tot;
  24. getch();
  25. }

Write a program to store product number, price of each item, & quantity and calculate total ammount, then find disocunt at 30% and Generate bill

Filed under: bill,cin,cout — snehilkhanor @ 1:51 am
Product number, price of each item and quantity are taken from the user and dicount and net ammount is calculated.
Bill is Displayed as follows:
Product ID:
Quantity:
Total ammount:
Discount:
Net ammount:

Select To use this code as it is.. select and copy paste this code into code.cpp file :)
  1. #include <iostream.h>
  2. #include <conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. int id,qty;
  7. float tot,amt,price,dis;
  8. cout<<”Enter Product ID: “;
  9. cin>>id;
  10. cout<<”Please Enter Quantity: “;
  11. cin>>qty;
  12. cout<<”Please Enter Price per ITEM: INR “;
  13. cin>>price;
  14. tot=qty*price;
  15. dis=.3*tot;
  16. amt=tot-dis;
  17. cout<<”\n\n\nProduct ID: “<<id<<”\nQuantity: “<<qty<<”\nPrice Per ITEM: INR
  18. “<<price<<”\nTotal amt: INR “<<tot<<”\nDiscount @ 30% : INR “<<dis<<”\nNet
  19. Ammount: INR “<<amt;
  20. getch();
  21. }

July 5, 2009

Write a program to store product ID and sales ammount and calculate discount accordin to condition and calculate net ammount

Filed under: bill,cin,cout,else if,if,if else — snehilkhanor @ 6:45 pm
Take Product ID and Sales ammount from user.
Calculated Discount ammount according to condition:
If amt < 5000 then discount = 20%
If ammount >= 5000 And <= 10000 then discount = 30%
otherwise discount= 40%

Select To use this code as it is.. select and copy paste this code into code.cpp file :)
  1. #include <iostream.h>
  2. #include <conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. float id,amt,pd,d,net;
  7. cout<<”Please enter product ID: “;
  8. cin>>id;
  9. cout<<”Please enter Sales ammount: “;
  10. cin>>amt;
  11. if (amt<5000)
  12. d=.2*amt;
  13. else if (amt>=5000 && amt<=10000)
  14. d=.3*amt;
  15. else
  16. d=.4*amt;
  17. net=amt-d;
  18. cout<<”Discount= “<<d;
  19. cout<<”\nNet ammount= “<<net;
  20. getch();
  21. }

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.