Need some help write this for My class!

Write a program to calculate semester fees that must be paid by a student at a State university using the following values:
Each semester unit $90.00
Regular room charge $200.00
Air conditioned room $250.00
Food charge $400.00
Matriculation fee (all students) $30.00
Diploma fee (if graduating student) $35.00

Input student ID number (one integer containing four digits), the type of a room (regular or air conditioned as one letter R/A), number of units, and whether or not the student is graduating (Y/N). Output an itemized list of student fees and a total of the student fee owed. Check for students taking more than 21 units and students taking fewer than 12 units. Output a message to students enrolled in more than 21 units (this is not allowed, do NOT process this data) or fewer than 12 units (warn them that they are not full time students but DO process this data).

Input
Student identification number, type of room (R, A), number of units, and whether or not student is graduating (Y/N). If there is an error in input (units, type of room, number of units, graduating or not) output all student data and a specific error message and do NOT process any student record that contains any error data.
This is not a homework site. We won't do your homework for you. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.
What help is needed? Have you produced a program design? Do you understand how this would be done using pen/paper? What are the instructions you would give to someone else to do this who didn't know the requirements?

Once you have the design, then you can start coding. Code in small parts and compile and test frequently. Don't try to write the whole program at once then compile and find there are many compile errors.

What C++ issue are you having problems with? Can you display text, obtain values etc? Post your current code.
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
const float UNIT = 90.00;
const float RROOM = 200.00;
const float ACROOM = 250.00;
const float FOOD = 400.00;
const float MATRI = 30.00;
const float DIPLOM = 35.00;
const int N = 10;
const int unit_min = 1;
const int unit_max = 21;
char letter = 'y';
int main ()


{
float Unitprice, Roomprice, Foodprice, Martriculationprice, Total;
int Units, StudentID;
char RoomType, Graduating , letter;
string RoomName;



cout << "Please enter number of units " ;
cin >> Units;
if (Units < unit_min || Units > unit_max )
{
cout <<" Unit can not be more than 21 or less than 1 " << endl;
cout <<" Please enter the valid number " << endl;
}
Unitprice = UNIT * Units;

cout << "Please enter your four digits student ID " ;
cin >> StudentID;


cout << "Please enter R for regular room or A for AC Room " ;
cin >> RoomType;
if (RoomType == 'R' || 'r')
{
Roomprice = RoomType * RROOM;
RoomName = "Regular";
}
else if (RoomType == 'A' || 'a')
{
Roomprice = RoomType * ACROOM;
RoomName = "AirCondtion";

}









cout << " Are you Graduating (Y or r) for yes and (N or n) for no " ;
cin >> Graduating;
while (!(letter == 'y') || (letter == 'Y') || (letter == 'n') || (letter == 'N'))
cout << "Error: You must enter Y for yes N for no" ;



Total = Unitprice + Roomprice+ FOOD + MATRI + DIPLOM ;
cout << fixed << showpoint << setprecision (2) << endl;

cout << "Prie of the Units $" << setw (N) << Unitprice << endl;
cout << "Food Charge $" << setw (N) << FOOD << endl;
cout << "AC Room price $" << setw (N) << ACROOM << endl;
cout << "Matricuation $" << setw (N) << MATRI << endl;
cout << "Total Semester Charge $" << setw (N) << Total << endl;
so far i got this far.
Thanks!
It's all over the place, but I think I'm getting there.
Something else that might help "getting there:"

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

How to use code tags: http://www.cplusplus.com/articles/jEywvCM9/

There are other tags available.

How to use tags: http://www.cplusplus.com/articles/z13hAqkS/

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

Some formatting & indentation would not hurt either
George, I'm glad you and others take the time to tell newbies how to format their code, but I think the use of all-caps in the 'PLEASE' part of your quoted message immediately discourages people from reading it, because it gives off the vibe that you're yelling at them. What's in it for them? Also, the double-spacing between each short sentence makes it overall harder to digest.

You will receive faster, better help if you format your source code to make it easier to read.
How to use code tags: http://www.cplusplus.com/articles/jEywvCM9/

There are other tags available.
How to use tags: http://www.cplusplus.com/articles/z13hAqkS/

Hint: You can edit your post and add code tags.
Last edited on
As formatted:

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
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

const float UNIT = 90.00;
const float RROOM = 200.00;
const float ACROOM = 250.00;
const float FOOD = 400.00;
const float MATRI = 30.00;
const float DIPLOM = 35.00;
const int N = 10;
const int unit_min = 1;
const int unit_max = 21;
char letter = 'y';

int main() {
	float Unitprice, Roomprice, Foodprice, Martriculationprice, Total;
	int Units, StudentID;
	char RoomType, Graduating, letter;
	string RoomName;

	cout << "Please enter number of units ";
	cin >> Units;

	if (Units < unit_min || Units > unit_max) {
		cout << " Unit can not be more than 21 or less than 1 " << endl;
		cout << " Please enter the valid number " << endl;
	}

	Unitprice = UNIT * Units;

	cout << "Please enter your four digits student ID ";
	cin >> StudentID;

	cout << "Please enter R for regular room or A for AC Room ";
	cin >> RoomType;

	if (RoomType == 'R' || 'r') {
		Roomprice = RoomType * RROOM;
		RoomName = "Regular";
	} else if (RoomType == 'A' || 'a') {
		Roomprice = RoomType * ACROOM;
		RoomName = "AirCondtion";
	}

	cout << " Are you Graduating (Y or r) for yes and (N or n) for no ";
	cin >> Graduating;

	while (!(letter == 'y') || (letter == 'Y') || (letter == 'n') || (letter == 'N'))
		cout << "Error: You must enter Y for yes N for no";

	Total = Unitprice + Roomprice + FOOD + MATRI + DIPLOM;
	cout << fixed << showpoint << setprecision(2) << endl;

	cout << "Prie of the Units $" << setw(N) << Unitprice << endl;
	cout << "Food Charge $" << setw(N) << FOOD << endl;
	cout << "AC Room price $" << setw(N) << ACROOM << endl;
	cout << "Matricuation $" << setw(N) << MATRI << endl;
	cout << "Total Semester Charge $" << setw(N) << Total << endl;
}


As a starter:

L39/42 don't do what you think they do. See L26
L15/L20. letter is defined in both. L15 will be ignored.
L48 Input is to Graduating - but you test letter in the condition L50
L50 If letter is not a y or n then you'll get an infinite loop of messages as letter isn't changed in the loop

Lines 26-29: If the number of units is out of range, you output a message and then keep going as if nothing was wrong. Your instructions specifically state
do NOT process any student record that contains any error data.


Line 26: You have not checked for less than 12 units.
fewer than 12 units (warn them that they are not full time students but DO process this data)


Lines 39,42: C++ does not support implied left hand side in conditionals. You must fully specify the conditions.
Example:
if (ans == 'Y' || 'y') evaluates as if ((ans == 'Y') || ('y'))

('y') always evaluates to 1 (true), therefore the if statement is always true.

Line 50: The ! negates only the first condition. You need parenthesis around all the conditions.

Topic archived. No new replies allowed.