Struggling to understand what I would need to create a program with these requirements

I'm sorry im very new to programming and I know asking this will be bothersome.
I was asked to create a program that has certain requirements. I'm not sure what type of things i need to include inside my program to fulfill them. I'm not asking for you to type code for me but to help me understand what it is I need to do. Here are the requirements.

Ask the user who their TDU is.
Ask the user how many kWh they used in the month.
Calculate the TDU charges based on the kWh the user entered and the TDU they selected.
Display the charges with a brief explanation to the user.
Ask the user if they want to enter another month. If so, allow the user to go through the process again.
Also please don't just send me links for learning about cout and cin

Last edited on
'Ask' requires a display (cout) and input (cin). So you need the program to do 2 'asks'. Then perform the calculation (is this defined somewhere?). 'Display charges' is a cout, 'Ask' for another month is again cout/cin. Then there is a loop to repeat if needed.

If you already know about cout/cin, then exactly what part of this requirement are you having difficulty with?? Can you do this for 1 month? Post the code you have so far.
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
Topic archived. No new replies allowed.