PLEASE HELP-can't find the soultion

//*********************** Preprocessor Directives *********************
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <stdlib.h>
#include <cstdlib>


using namespace std;

//******************************* main ********************************
int main()
{ //Declaration Section
const double TAX_RATE = 0.07,
PRINT_RATE = 0.50;

int print_num;
double print_cost; // reprint_num * print_num
double bal_due; // print_total * PRINT_RATE
double tax_amt; //print_total * TAX_RATE
double tot_cost, //rental_cost * tax_amt
int reprint_num; //
char name[30]; // customer name (first and last)
char date[12]; // format mm/dd/yyyy

// input section
system ("cls");
cout << "Enter Today's Date: ";
cin >> date;
cout << "Enter Customer Name: ";
cin >> ws;
cout << "Enter The Print Number: ";
cin >> print_num;
cout << "Enter the Reprint Number: ";
cin >> reprint_num;

//process section
print_cost = reprint_num * print_num
bal_due = print_total * PRINT_RATE
tax_amt = print_total * TAX_RATE
tot_cost = rental_cost + tax_amt
// output section
system("cls");
cout << setiosflags(ios::showpoint | ios::fixed) << setprecision (2) << fixed;
cout << "MOREPRINTS Photo Store" << endl;
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~" << endl << endl;
cout << "Date " << date << endl << endl;
cout << "Customer " << name << endl << endl;
cout << "Photos In " << print_num << endl << endl;
cout << "Reprints Ordered " << reprint_num << endl;
cout << "Total Reprints " << print_cost << endl;
cout << "Price/Reprints " << PRINT_RATE << endl << endl;
cout << "Reprint Cost " << bal_due << endl;
cout << "Tax Amount " << tax_amt << endl;
cout << "Total Cost " << tot_cost << endl;
cout << endl << endl; //provides blank line before pause display message
system("pause");
return 0;
}
Last edited on
Delete the group of variables that you put before main (that's not where to put them). Leave the ones that you still have inside main, but look closely at the punctuation. Maybe delete those comments to see it better.

Later on in your code (before all the couts at the end) you are missing semicolons at the end of your lines.

And if you post code again, make sure you put it in [code] [/code] tags.
Learning how to deal interpret compiler errors is an important tool to have.
Compiler errors will often point to a line where it thinks something went wrong. It's usually helpful to start looking at that line. Also, if you have multiple errors, always start with the first one in the list.
14:1: error: 'prnt_cost' does not name a type


1
2
3
4
5
6
7
8
9
int prnt_num; 
double reprnt_num;
prnt_cost, // reprnt_num * prnt_num
bal_due, // prnt_total * PRINT_RATE
tax_amt, //prnt_total*TAX_RATE tot_cost, //rental_costtax_amt 
prnt_num	// number of prints
reprnt_num	// number of reprints
char name[30], // customer name (first and last) 
date[12], // format mm/dd/yyyy  


I think you're confusing yourself by trying to make all these variable declarations part of the same statement.

Just declare each variable you need on its own line.

1
2
3
4
5
6
7
int prnt_num; 
double prnt_cost; // reprnt_num * prnt_num
double bal_due; // prnt_total * PRINT_RATE
double tax_amt; //prnt_total*TAX_RATE tot_cost, //rental_costtax_amt 
int reprnt_num;	// number of reprints
char name[30]; // customer name (first and last) 
char date[12]; // format mm/dd/yyyy  


It also looks like you're declaring variables more than once. A variable should only be declared once in the same scope.

reprnt_num
Your keyboard isn't dying, you don't need to unnecessarily leave out vowels. reprint_num is much easier to reach, and search for (search for all instances of "print" for example).

base_cost =reprnt_num * prnt_num
 In function 'int main()':
38:1: error: 'base_cost' was not declared in this scope
23:14: warning: unused variable 'TAX_RATE' [-Wunused-variable]
 

You never define base_cost.
Last edited on
I changed everything you suggested, but it is still coming up with errors I don't know how to fix lol. Like "an unqualified-id before 'int' and "reprint_num isn't declared" in my input section
Last edited on
Show your current code along with the exact error messages. Then maybe someone might be able to help you understand what the compiler/linker is saying about your code.

At line 29, the error is "expected unqualified-id before 'char" and at line 49 the error is "reprint_num was not declared in this scope." I checked the punctuation and I can't find anything, but besides that I don't know what else to do. And I updated the code so it's exactly what I have currently.
Last edited on
Put your code in code tags so we can see it and check it more easily. Like this:
[code]
your code here
[/code]

You still have a comma where it should be a semicolon in your declarations.
And you didn't fix the missing semicolons I mentioned on the lines in your "process section".
Last edited on
Sorry this is my first time using the site so I'm getting used to the lingo lol
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//*********************** Preprocessor Directives ********************* 
#include <fstream> 
#include <iostream> 
#include <iomanip> 
#include <string> 
#include <cmath> 
#include <stdlib.h> 
#include <cstdlib>


using namespace std;

//******************************* main ******************************** 
int main() 
{ //Declaration Section 
const double TAX_RATE = 0.07, 
PRINT_RATE = 0.50; 

int print_num; 
double print_cost; // reprint_num * print_num
double bal_due; // print_total * PRINT_RATE
double tax_amt; //print_total * TAX_RATE 
double tot_cost; //rental_cost * tax_amt 
int reprint_num; // 
char name[30]; // customer name (first and last) 
char date[12]; // format mm/dd/yyyy 

// input section 
system ("cls"); 
cout << "Enter Today's Date: "; 
cin >> date; 
cout << "Enter Customer Name: "; 
cin >> ws; 
cout << "Enter The Print Number: "; 
cin >> print_num; 
cout << "Enter the Reprint Number: "; 
cin >> reprint_num; 

//process section 
print_cost = reprint_num * print_num
bal_due = print_total * PRINT_RATE 
tax_amt = print_total * TAX_RATE 
tot_cost = rental_cost + tax_amt 
// output section 
system("cls"); 
cout << setiosflags(ios::showpoint | ios::fixed) << setprecision (2) << fixed; 
cout << "MOREPRINTS Photo Store" << endl; 
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~" << endl << endl; 
cout << "Date " << date << endl << endl; 
cout << "Customer " << name << endl << endl; 
cout << "Photos In " << print_num << endl << endl; 
cout << "Reprints Ordered " << reprint_num << endl; 
cout << "Total Reprints " << print_cost << endl; 
cout << "Price/Reprints " << PRINT_RATE << endl << endl; 
cout << "Reprint Cost " << bal_due << endl; 
cout << "Tax Amount " << tax_amt << endl; 
cout << "Total Cost " << tot_cost << endl; 
cout << endl << endl; //provides blank line before pause display message 
system("pause"); 
return 0; 
}

I fixed the comma thing you pointed out, so now the only error is at line 46 and says "expected ';' before 'bal_due'"
line 46 and says "expected ';' before 'bal_due'"
It's saying it expects a ; before bal_due. If you were to put a ; before bal_due, that particular error would go away.

But what it's actually saying is that you forgot to end the previous line with a ;.
You need to end the line before the line where you have bal_due (line 40) with a ;

Apply this to the other statements where you forgot a ; on as well (lines 40-43).
Last edited on
So all of the errors are gone, but I'm not able to input the print number and reprint numbers that I need. I'm not sure if the ';' are stopping this but as soon as I enter the "customer name", it skips directly to the end.
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//*********************** Preprocessor Directives ********************* 
#include <fstream> 
#include <iostream> 
#include <iomanip> 
#include <string> 
#include <cmath> 
#include <stdlib.h> 
#include <cstdlib>

 
using namespace std;
 
//******************************* main ******************************** 
int main() 
{                            						//Declaration Section   
 const double TAX_RATE = 0.07,                        
 			  PRINT_RATE = 0.50;    
 
int print_num; 
double print_total; // reprint_num * print_num
double bal_due; // print_total * PRINT_RATE
double tax_amt; //print_total * TAX_RATE 
double tot_cost; //bal_due * tax_amt 
char reprint_num; // number of reprints
char name[30]; // customer name (first and last) 
char date[12]; // format mm/dd/yyyy                 
    												
													// input section   
system ("cls");   
cout <<  "Enter Today's Date:  ";   
cin >> date;   
cout <<  "Enter Customer Name:  ";   
cin >> ws;   
cout <<  "Enter The Print Number:  ";   
cin >>  print_num;   
cout <<  "Enter the Reprint Number:  ";   
cin >>  reprint_num;   
														
														//process section   
print_total = reprint_num * print_num;
bal_due = print_total * PRINT_RATE;   
tax_amt = print_total  * TAX_RATE;                             
tot_cost = bal_due + tax_amt;								                                   								
													// output section   
system("cls");                  
cout << setiosflags(ios::showpoint | ios::fixed) << setprecision (2) << fixed;   
cout << "MOREPRINTS Photo Store"  << endl;   
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~"  << endl  << endl;   
cout << "Date        " << date << endl  << endl;   
cout << "Customer    " << name << endl << endl;   
cout << "Photos In         " << print_num  << endl << endl;   
cout << "Reprints Ordered   "  << reprint_num  << endl;   
cout << "Total Reprints  " << print_total  << endl;   
cout << "Price/Reprints   " << PRINT_RATE << endl << endl;   
cout << "Reprint Cost       " << bal_due << endl;   
cout << "Tax Amount        " << tax_amt << endl;   
cout << "Total Cost        " << tot_cost << endl;        
cout << endl << endl;         //provides blank line before pause display message  
system("pause");  
return 0; 
}

Last edited on
Before you go, note some things.

1. <stdlib.h> is a C header, not a C++ header. You included the C++ header version on line 8, so I would remove line 7.

2.
1
2
3
4
cout <<  "Enter Today's Date: f ";   
cin >> date;   
cout <<  "Enter Customer Name:  ";   
cin >> ws;   


Your comment for name states "// customer name (first and last)". You (a) never fill in a value for name, and even if you were to, (b) the use of std::cin >> name; doesn't allow for spaces.

What I would rather do is use getline to handle user string input safely. This also prevents the user from overflowing your buffer (30 characters for name, 12 for date) (although more logic would be necessary to properly prevent bad data).
1
2
3
4
5
6
7
8
9
10
11
cout <<  "Enter Today's Date:  ";  
cin.getline(date, 12);

cout <<  "Enter Customer Name:  ";   
cin.getline(name, 30);

cout <<  "Enter The Print Number:  ";   
cin >>  print_num;   

cout <<  "Enter the Reprint Number:  ";   
cin >>  reprint_num; 


Another caveat... not an issue with your code, but in the future, note that if you use getline after using cin >>, you need to add a cin.ignore(); call before the getline call to erase the remaining previous newline in cin's buffer. A bit annoying.
Last edited on
Now the issue I'm having is that the "tax.amt" isn't doing the calculation. I had to remove the double because it made the program work incorrectly. The equation to me and the program as a whole looks okay, but I don't know what's stopping the "tax.amt" function when everything else is working fine.
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
48
49
50
//******************************* main ******************************** 
int main() 
{                            						//Declaration Section   
 const double 
 TAX_RATE = 0.07,                        
 PRINT_RATE = 0.50;    
 
int print_num; 		//print number
int print_total; // reprint_num * print_num
int bal_due; 	// print_total * PRINT_RATE
int tax_amt; 	//print_total * TAX_RATE 
int tot_cost; 	// bal_due + tax_amt 
int reprint_num; 	// number of reprints
char name[30]; 		// customer name (first and last) 
char date[12]; 		// format mm/dd/yyyy                 
    												
													// input section   
system ("cls");   
cout <<  "Enter Today's Date:  ";  
cin.getline(date, 12);
cout <<  "Enter Customer Name:  ";   
cin.getline(name, 30);
cout <<  "Enter The Print Number:  ";   
cin >>  print_num;   
cout <<  "Enter the Reprint Number:  ";   
cin >>  reprint_num;   
														
														//process section   
print_total = reprint_num * print_num;
bal_due = print_total * PRINT_RATE;   
tax_amt = print_total  * TAX_RATE;                         
tot_cost = bal_due + tax_amt;							                                   								
													// output section   
system("cls");                  
cout << setiosflags(ios::showpoint | ios::fixed) << setprecision (2) << fixed;   
cout << "MOREPRINTS Photo Store"  << endl;   
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~"  << endl  << endl;   
cout << "Date        " << date << endl  << endl;   
cout << "Customer    " << name << endl << endl;   
cout << "Photos In         " << print_num  << endl << endl;   
cout << "Reprints Ordered   "  << reprint_num  << endl;   
cout << "Total Reprints  " << print_total  << endl;   
cout << "Price/Reprints   " << PRINT_RATE << endl << endl;   
cout << "Reprint Cost       " << bal_due << endl;   
cout << "Tax Amount        " << tax_amt << endl;   
cout << "Total Cost        " << tot_cost << endl;        
cout << endl << endl;         //provides blank line before pause display message  
system("pause");  
return 0; 
}
There's no such thing as a "tax.amt function" in your program. It's important to know the correct terminology so that we can communicate efficiently.

tax_amt is a variable, and a value (perhaps from a calculation) is assigned to it.

What do you mean by "it isn't doing the calculation"? When I run your program, it is definitely showing me a value for tax_amt.
Enter Today's Date:  1/2/3
Enter Customer Name:  Buddy H
Enter The Print Number:  3
Enter the Reprint Number:  5
MOREPRINTS Photo Store
~~~~~~~~~~~~~~~~~~~~~~~~~

Date        1/2/3

Customer    Buddy H

Photos In         3

Reprints Ordered   5
Total Reprints  15
Price/Reprints   0.50

Reprint Cost       7
Tax Amount        1
Total Cost        8


If you're wondering why it's cutting off the digits after the decimal place, that's because you have bal_due, tot_cost, and tax_amt as int types. An int can't store non-integer numbers.

Change it back to a double and then explain what's actually wrong.
Last edited on
Thank you so much, that fixed it! I appreciate it immensely! Hopefully I'll get the hang of it soon enough lol
Topic archived. No new replies allowed.