Help in Visual Studio C++

closed account (Evfo2yTq)
Ask the user the name of the person the bill is being calculated for.
Ask the user how many months worth of data they want to enter (up to 12).
Ask the user who their TDU is.
Take the kwh used for each month from the user.
Calculate the charges for each month based on the rates specified in the EFL.
Calculate the TDU charges based on the kWh the user entered and the TDU they selected.
Display the user's name & the charges for each month (show the electric company charges, the TDU charges, and the total charges of both combined).
Display the user's name & the total charges for all months added together (show electric company charges, TDU charges, and total charges of both combined).
Allow the user to enter another person's billing information.
Your program MUST have comments explaining your code. The more detail, the better.
If your program does not run for any reason, it will be graded as a 0. Test your code before submitting.


#include <iostream>
#include <string>

using namespace std;

int main();
{
int x;
int n;
int month;
int TDU;

cout << "What is your name? " << endl;
//Asks for your name
cin >> x;
//Allows you to input your name

cout << "How many months worth of data do you want to enter? " << endl;
//Asks for # of months you want to enter
cin >> month;
//Allows input for # of months

cout << "Enter the name of TDU: " << endl;
//Asks for TDU Name
cin >> TDU;
//Allows user to input TDU

cout << "Enter the usage in kWh used: " << endl;
//Asks for usage
cin >> n;

double Oncor = 3.42 + (.0384470 * 1000);
double CenterPointEnergy = 5.47 + (.0403120 * 1000);
double AEPTexasCenteral = 9.00 + (.0448460 * 1000);
double AEPTexasNorth = 10.53 + (.0401990 * 1000);
double TexasNewMexicoPower = 7.85 + (.0483210 * 1000);
// Calculations

cout << "TDU Delivery charges for " << TDU << " : " << "total" << endl;
//Tells user the total TDU Delivery charges
cout << "Enter 1 to calculate bill for another month, 0 to exit" << endl;
//Lets user input 1 or 0 to continue or exit
cin >> n;


return 0;
}

Can someone help me?
Last edited on
Can someone help me?

Well, for starters.....
PLEASE learn to use code tags, they make reading and commenting on source code MUCH easier.

http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/

HINT: you can edit your post and add code tags.

Some formatting & indentation would not hurt either
Can someone help me?


Even though you should have read the forum posting instructions, code-tags won't help you much because you are making some desperately basic errors - probably by not reading your class notes or text.

I'm not going to do your homework for you - somebody else might.

However, despite that you need to concentrate now on the calculation lines starting at double OnCor etc. Those lines are currently hardcoded by you and should be written so the calculation takes into account the input from the end-user. Also, as a tip, the input would be better as a double, not int. At first glance it doesn't appear to be an issue but it has all the markings of causing strife.

You're going to need a while or some other loop with escape code. That'll come later after you get the fundamentals right and produce at least 1 bill :)

And last, give the variables meaningful names - x & n mean zip - customer_name & usage - go a long way to making your code clear without a whole pile of irrelevant and redundant comments.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream> // <--
#include <string>

using namespace std;

int main() // <--
{
    string x; // <--
    double n; // <--
    int month;
    string TDU; // <--
    
    cout << "What is your name? " << endl;
    //Asks for your name
    cin >> x;
    //Allows you to input your name
    
    cout << "How many months worth of data do you want to enter? " << endl;
    //Asks for # of months you want to enter
    cin >> month;
    //Allows input for # of months
    
    cout << "Enter the name of TDU: " << endl;
    //Asks for TDU Name
    cin >> TDU;
    //Allows user to input TDU
    
    cout << "Enter the usage in kWh used: " << endl;
    //Asks for usage
    cin >> n;
    
    double Oncor = 3.42 + (.0384470 * 1000);
    double CenterPointEnergy = 5.47 + (.0403120 * 1000);
    double AEPTexasCenteral = 9.00 + (.0448460 * 1000);
    double AEPTexasNorth = 10.53 + (.0401990 * 1000);
    double TexasNewMexicoPower = 7.85 + (.0483210 * 1000);
    // Calculations
    
    cout << "TDU Delivery charges for " << TDU << " : " << "total" << endl;
    //Tells user the total TDU Delivery charges
    cout << "Enter 1 to calculate bill for another month, 0 to exit" << endl;
    //Lets user input 1 or 0 to continue or exit
    cin >> n;
    
    
    return 0;
}
Last edited on
.. so the OP just closes the account!
seeplus wrote:
.. so the OP just closes the account!
I guess the OP didn't feel like they had a warm and friendly reception...🤔
I guess the OP didn't feel like they had a warm and friendly reception...🤔
That's a bit ambiguous.
Registered users can post here. Sign in or register to post.