Ok Yes I admit it I'm a student with a homework problem but I'm using this forum as a last resort. I've already written the code and I can't find the error no matter how many times I look over it so I really just need a second set of eyes. Don't tell me how to fix it just tell me what line/lines it is in and I'll figure it out myself.

// Weighted Average program
// Written by Will Styers CIS115-01

#using <mscorlib.dll>
using namespace System;

int main()
{
	//declaration of variables
	int test1        = 0;
	int test2        = 0;
	int test3        = 0;
	int lab1         = 0;
	int lab2         = 0;
	int lab3         = 0;
	int lab4         = 0;
	int lab5         = 0;
	int exam         = 0;
	int avgt         = 0;
	int avgl         = 0;
	int finalAverage = 0;

	//asking for user input

	Console::Write("Enter first test:");
	test1 = Console::ReadLine();
	Console::Write("Enter second test:");
	test2 = Console::ReadLine();
	Console::Write("Enter third test:");
	test3 = Console::ReadLine();
	Console::Write("Enter first lab:");
	lab1 = Console::ReadLine();
	Console::Write("Enter second lab:");
	lab2 = Console::ReadLine();
	Console::Write("Enter third lab:");
	lab3 = Console::ReadLine();
	Console::Write("Enter fourth lab:");
	lab4 = Console::ReadLine();
	Console::Write("Enter fifth lab:");
	lab5 = Console::ReadLine();
	Console::Write("Enter final exam:");
	exam = Console::ReadLine();

	//Equations

	avgt = (test1 + test2 + test3)/3;
	avgl = (lab1 + lab2 + lab3 + lab4 + lab5)/5;
	finalAverage = (avgt * .30) + (avgl * .50) + (exam * .20);

	//output statement

	Console::WriteLine("The final average is {0}.",Convert::ToString(finalAverage));

	return 0;
}	//End main function

Recommended Answers

All 5 Replies

First, I think you should declare avgt, avgl and finalAverage as float or double. But could be useful if you specify what kind of error you get.

Hmm yeah you're probably right about the data types. I wasn't thinking. Here is the error message I got. I looked it up on Microsoft but to no avail.

fatal error C1010: unexpected end of file while looking for precompiled header directive

I forgot to slip that 1 in there in the thread title.

Hmm yeah you're probably right about the data types. I wasn't thinking. Here is the error message I got. I looked it up on Microsoft but to no avail.

fatal error C1010: unexpected end of file while looking for precompiled header directive

I forgot to slip that 1 in there in the thread title.

Take a look on this: http://www.myserverproject.net/forum/viewtopic.php?t=35. Maybe it will help you.

Ok I read that thread and gave that a shot now it's not converting the String input in the Console::Readline statements to int. Usually it converts automatically. Will I have to typecast those now?

According to MSDN, the Readline method returns a string, so I think you have to do the typecast - lab1 = Convert.ToInt (Console::Readline)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.