Blank compile screen

I have two problems that I have stared at and tried editing to get them to compile.. Can someone please look at these from another view and tell me what I am doing wrong?



Problem:

should include a while loop that allows the user to continue entering employees as long as they want to continue.


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
int main()
 {
 Real payrate,hours, gross;

 int again = 1;

 while (again == 1);
 {

 cout << "Enter the employees hourly pay rate. \n";
 cin >> payrate;

 cout<< "Enter the total hours worked by employee. \n";
 cin >> hours;

 while (payrate > 18.25 || payrate < 7.50)
 {
 cout << "The valid value for pay rate is in the range. \n";
 cout << " of $7.50 through $ 18.25. \n";
 cout << "Enter a valid value for pay rate. \n";
 cin >> payrate;
 }

 while (hours > 40 || hours < 0)
 {
 cout << "Please enter hours worked between 0 and 40. \n ";
 cin >> hours;
 }


 gross = payrate * hours;
 cout << "The gross pay of the employee is $ " << gross << endl;

 cout << "Do you want to continue for another employee? Enter 1 for yes \n";
 cout << "or 0 for no." << endl;
 cin >> again;
 }

 }




Problem:

include a loop that displays income generated from ticket sales for each night. Shows are performed on Thursday, Friday and Saturday nights.




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
int main()
 {
 int A, B, C ;
 int TotalIncome[3];
 for (int i=0; i<3; i++);
 {


 cout << "Enter number of seats sold in Section A: \n";
 cin >> A;

 cout << "Enter number of seats sold in Section B: \n";
 cin >> B;

 cout << "Enter a number of seats sold in Section C: \n";
 cin >> C;

 while (A < 0 or A > 300)
 {
 cout << "ERROR: Seats sold in Section A cannot be \n";
 cout << "greater than 300 or negative.\n ";

 cout << "Enter valid value for seats sold in section A: \n";
 cout << "A value in the range of 0 to 300 inclusive. \n";
 cin >> A;
 }
 while (B < 0 or B > 500)
 {
 cout << "ERROR: Seats sold in Section B cannot be \n";
 cout << "greater than 500 or negative.\n ";

 cout << "Enter valid value for seats sold in section C: \n";
 cout << "A value in the range of 0 to 500 inclusive. \n";
 cin >> B;
 }
 while (C < 0 or C > 200)
 {
 cout << "ERROR: Seats sold in Section C cannot be \n";
 cout << "greater than 200 or negative.\n ";

 cout << "Enter valid value for seats sold in section C: \n";
 cout << "A value in the range of 0 to 200 inclusive. \n";
 cin >> C;
 }
 TotalIncome[i] = (A * 20) + (B * 15) + (C * 10);
 }
 for (int i=0; i<3; i++)
 {

 cout << "The total income generated from ticket sales \n ";
 cout << "of all sections is $ " << TotalIncome;
 }
}

Last edited on
I'm not sure what is meant by "Blank compile screen". Each of these programs has an error which will be reported by your compiler. If the screen is blank, something isn't configured correctly, or you're looking in the wrong place.

The first gives the message:
[Error] 'Real' was not declared in this scope

followed by some other messages which are related to that one.

The second gives the message:
[Error] 'i' was not declared in this scope


your first step should be to check that you get messages similar to this (the wording may differ), and then use them to track down the problems. Note the message will give the line number too, which helps, though in the second example the actual error is on an earlier line.
When I select builds and compile it runs through and when the screen pops up for my input it just shows a black screen. So I just need help finding the errors in my code so I can fix the problems. In the first problem I think it might be something with my while loop because it does not ask me do I want to run again. In the second problem it does not ask me to enter the info for the days. It only runs and returns info for one.
This cannot be the actual code which is giving you problems, since neither of them will even compile successfully.
I should have mentioned I am still trying to work on it... I removed the while (again==1),tried changing the || to &&, int TotalIncome[3]
for (int i=0; i<3; i++) and tried moving it around... tried index.. Basically tried or think I have tried everything within my book... I am still very new as this is only my fifth week in my programming class never having any other experience in C++ before.
First program:
Line 3: Real is not a valid C++ data type. Use float or double

Line 1: You need to include:
1
2
#include <iostream>
using namespace std;


Second program:
Line 1: You need to include:
1
2
#include <iostream>
using namespace std;


Line 48: i is undefind. i was defined only within the scope of the for loop. This statement is outside the for loop, therefore i is undefined.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/

Ok i fixed that... did not know it showed highlighted with the <>... on my codeblocks lines 1 and 2 are included in my code.. i just highlighted and copied the code itself onto the forum
Topic archived. No new replies allowed.