Hello Swaggywhale,
I found this useful for understanding how to use the tags:
http://www.cplusplus.com/articles/z13hAqkS/
You wrote: |
---|
I'm sorry im very new to programming |
So Start by telling everyone what you do know and what you have learned so far.
It looks like you know about "cin" and "cout" as for "endl" most places where you use it you can get by with using the new line (\n) in its place. Save the "endl" for the last line or when you really need it.
1- Ask the user who their TDU is.
2 - Ask the user how many kWh they used in the month.
3 - Calculate the TDU charges based on the kWh the user entered and the TDU they selected.
4 - Display the charges with a brief explanation to the user.
5 -Ask the user if they want to enter another month. If so, allow the user to go through the process again.
|
Using what you have learned, start by writing something down on paper to give you an idea of what the program needs to do. You could use a flow chart, pseudo code or just an idea of what needs done.
Work in small parts. Start with #1. Write the prompt to the screen and get the user input. Compile and test until you have what you want. Then add step #2. and repeat the Compile and test until you have what you want.
When you have something worked out for steps 1 and 2 post your code. Someone may see something that you have missed or a better suggestion.
When writing a prompt to the user I quite often have seen this and it is what I like to do:
1 2
|
std::cout << "\n Who is your TDU?: ";
std::getline(std::cin, tud);
|
My point here is the opening "\n " is not required, it is just makes it easier for me to read the screen and I think it looks a little nicer. The ending
TDU: ";
The (:) is not required. You can use any character you like, maybe (>), but the space is required. By leaving out any "\n"s or "endl"s the following input line will start on the same line as the prompt. The output would be:
Who is your TDU?: What you enter
|
Work something up and post your code.
Andy