how to write a program in c++ for this type of question?


Write a calculator program in c++ that allows the user to select which operation they would like to perform such as:
Addition,
subtraction,
multiplication,
division,
modulus,
Square,
Square root,
Convert Celsius to Fahrenheit (Fahrenheit = 1.8 Celsius +32),
Convert Celsius to Kelvin (add 273.15 °),
Convert Fahrenheit to Celsius (Celsius = (F-32) x (5/9)),
Convert Fahrenheit to Kelvin (Kelvin = 5/9 x (Fahrenheit - 32) + 273).

Make sure your program contains menu and will keep on looping until the user enter a specific value to end it. Please use Functions to do the calculation. You might want to use switch for the menu.

how to write this....?


question 2:


A parking garage charges a RM2.00 minimum fee to park for up to three hours. The garage charges an additional RM0.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24 hour period is RM10.00. Assume that no car parks for longer than 24 hours at a time. Write a program that will calculate and print the parking charges for each of 3 customers who parked their cars in this garage yesterday. You should enter the hours parked for each customer. Your program should print the results in a neat tabular format and should calculate and print the total of yesterday’s receipts. The program should use FUNCTION to determine the charge for each customer.

Recommended Answers

All 2 Replies

how to write a program in c++ for this type of question?


Write a calculator program in c++ that allows the user to select which operation they would like to perform such as:
Addition,
subtraction,
multiplication,
division,
modulus,
Square,
Square root,
Convert Celsius to Fahrenheit (Fahrenheit = 1.8 Celsius +32),
Convert Celsius to Kelvin (add 273.15 °),
Convert Fahrenheit to Celsius (Celsius = (F-32) x (5/9)),
Convert Fahrenheit to Kelvin (Kelvin = 5/9 x (Fahrenheit - 32) + 273).

Make sure your program contains menu and will keep on looping until the user enter a specific value to end it. Please use Functions to do the calculation. You might want to use switch for the menu.

how to write this....?


question 2:


A parking garage charges a RM2.00 minimum fee to park for up to three hours. The garage charges an additional RM0.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24 hour period is RM10.00. Assume that no car parks for longer than 24 hours at a time. Write a program that will calculate and print the parking charges for each of 3 customers who parked their cars in this garage yesterday. You should enter the hours parked for each customer. Your program should print the results in a neat tabular format and should calculate and print the total of yesterday’s receipts. The program should use FUNCTION to determine the charge for each customer.

Take apart your car (or television is always a good backup) and then it will all become clear to you.

i have made a basic calculator that shows the answer to everything,

eg, how the software runs

Enter first number 1
Enter second number 2

1 + 2 = 3
1 - 2 = -1
1 divided by 2 = 0.5
1 * 2 = 2

press 1 to continue using the calculator, press 2 to exit,

#include<iostream>

using namespace std;

int main()
{
float A = 0;  // user input 1 
float B = 0;  // user input 2
float total = 0; // total of input 1 and input 2 with addition
float total2 = 0; // total of input 1 and input 2 with subtraction
float total3 = 0;  // total of input 1 and input 2 with division
float total4 = 0;  //  total of input 1 and input 2 with mulitiplaction
int restart = 0;  // continue or exit application
	
cout << "Welcome to a Calculator Please enter your Math question!! " << endl;

cout << endl;
loop: // loops the program if user continues
cout << "Enter first Number "; 
cin >> A; // lets the user input first value
cout << endl;
	
cout << "Enter second number ";
cin >> B; // lets the user input second value
cout << endl;
	
total = A + B; // works out addition of A and B
cout << A << " + " << B << " = " << total << endl; 
	
total2 = A - B; // works out subtraction of A and B
cout << A << " - " << B << " = " << total2 << endl;
	
total3 = A / B; // works out division of A and B
cout << A << " divided by " << B << " = " << total3 << endl;
	
total4 = A * B; // works out mulitplaction of A and B
cout << A << " * " << B << " = " << total4 << endl;
cout << endl;
cout << endl;

cout << "Press 1 to continue using this calculator or 2 to exit ";
cin >> restart;
		if (restart == 1)
			{
			goto loop;
			}
			else
			{
			return 0;
			}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.