Hi there, I'm currently taking a beginners C++ course in college, and we were just assigned our first programming assignment. The problem is, my professor never actually explained how to put together a program and only talked about basic definitions. I'm supposed to write a program that computes tax and and possible totals with different tips on a restaurant bill when the meal total is entered. The tax should be 6.75% of the meal cost and the tips should be 10, 15, and 20 percent of the total after adding tax. I need to display the meal cost, tax amount, tip, and total bill on the screen.
I also need to write a program that asks for 5 test scores, then calculates the average and displays it.
I really have no idea how to write this program except for the most basic structure. Can someone please help get me started or give me an outline of what I'm supposed to write?
First step is to understand the problem. Have you learned about pseudocode? It could help you to break the problem down into small parts by using the human language.
Pseudocode is a cross between human language and a programming language. Although
the computer can’t understand pseudocode, programmers often find it helpful to write an
algorithm in a language that’s “almost” a programming language, but still very similar
to natural language. For example, here is pseudocode for program:
"Design, write and compile, and execute a C++ program that calculates and displays
the amount of money, A, available in N years when an initial deposit of X dollars
is deposited in a bank account paying an annual interest rate of R percent. Use
the relationship that A = X(1.0 + R/100)N. The program should prompt the user to
enter appropriate values and use cin statements to accept the data. Use statements
such as Enter the amount of the initial deposit in constructing your prompts."
Declare the variables
- A = amount of money
- N = number of years
- X = initial deposit
- R = interest rate
Ask the user for the number of years
Input the number of years
Ask the user for the initial deposit
Input the initial deposit
Ask the user for the interest rate.
Input the interest rate
Compute the amount of money (variable A) by using the formula A = X(1.0 + R/100)^N
Notice the pseudocode contains statements that look more like commands than the
English statements that describe the algorithm. The pseudocode even names variables and describes mathematical operations.
write a program that computes tax and possible totals with different tips on a restaurant bill when the meal total is entered. The tax should be 6.75% of the meal cost and the tips should be 10, 15, and 20 percent of the total after adding tax. I need to display the meal cost, tax amount, tip, and total bill on the screen.