Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issues with double variables in c++ 2011
#1
Code:
1. #include <iostream> 2. #include <iomanip> 3. using namespace std; 4. 5. void printbill(double kwhused, double rate, double charge, double tax, double total) 6. { 7. // Print Logo 8. cout << "pppppp oooooo w w w eeeeeeee rrrrrrr cccccc oooooo" << endl; 9. cout << "p p o o w w w e r r c c o o" << endl; 10. cout << "p p o o w w w e r r c o o" << endl; 11. cout << "pppppp o o w w w eeeeee rrrrrrr c o o" << endl; 12. cout << "p o o w w w e r r c o o" << endl; 13. cout << "p o o w w w e r r c o o..." << endl; 14. cout << "p o o w w w w e r r c c o o..." << endl; 15. cout << "p oooooo w w eeeeeeee r r cccccc oooooo ..." << endl << endl; 16. 17. // Print column headers 18. cout << setw(10) << "KW/H Used" << setw(10) << "Rate" << setw(10) << "Charge" << setw(10) << "Tax" << setw(10) << "Total"; 19. 20. // Print data 21. cout << setw(10) << kwhused << setw(10) << rate << setw(10) << charge << setw(10) << tax << setw(10) << total << endl << endl; 22. } 23. 24. int main() 25. { 26. // Declare constant variables(rate, taxrate) 27. const double rate = .001; 28. const double taxrate = .05; 29. 30. // Declare variables 31. double charge, kwhused, total, tax; 32. 33. // Get kw/hr use 34. cout << "Please input number of kilowatts used : " << endl << endl; 35. cin >> kwhused; 36. cout << endl << endl << endl; 37. 38. // Calculate charge 39. charge = rate * kwhused; 40. 41. // Calculate tax 42. tax = charge * taxrate; 43. 44. // Calculate total 45. total = tax + charge; 46. 47. // Call the printbill() function 48. printbill(kwhused, rate, charge, tax, total); 49. 50. return 0; 51. }
[Image: d3nwyuy0nl342s.cloudfront.net%2Fimages%2...ar-140.png]

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  what is the difference between 1. Double Right-Left Rotation 2. Double Left-Right Rot Vuhelper 0 2,018 01-04-2012, 10:37 PM
Last Post: Vuhelper
  how to insert a new node on AVL tree using double rotation? Vuhelper 0 2,676 01-04-2012, 10:31 PM
Last Post: Vuhelper
  we will apply single rotation and which will apply double rotation?2012 Vuhelper 0 1,939 01-04-2012, 10:29 PM
Last Post: Vuhelper
  array project code c++ 2011 Vuhelper 0 1,272 12-10-2011, 06:32 PM
Last Post: Vuhelper
  factorial in C++ code 2011 Vuhelper 0 943 12-10-2011, 06:31 PM
Last Post: Vuhelper
  stack during function call in C++ 2011 Vuhelper 0 2,025 11-05-2011, 05:05 PM
Last Post: Vuhelper
  What is the Thing Queue? in c++ 2011 Vuhelper 0 1,785 11-05-2011, 05:02 PM
Last Post: Vuhelper
  ASCII to char conversion code in C++ 2011 Vuhelper 0 1,720 11-05-2011, 05:01 PM
Last Post: Vuhelper
  How to write a summation in a sequence? C++ 2011-12 Vuhelper 2 1,355 09-19-2011, 04:53 AM
Last Post: Xpert
  GetPixel problem in c++ 2011-12 Vuhelper 0 2,504 09-18-2011, 07:12 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)