Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > The IT Pro > Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Programming A discussion forum for programs and programming used in tech-related businesses.

Reply
 
LinkBack Thread Tools
Old 04-07-2007, 02:37 PM   #1 (permalink)
Registered User
 
Join Date: Aug 2005
Location: Ohio
Posts: 207
OS: VISTA


C# unasighnd local variable?

ok im makeing a grade book program wich is most of the way done i put together a throw away program to learn to do the aritmitic in so i dont mess up my code that is structured and looking nice with usable out put.

any way i am geting a compile error unasighnd local variable final1 (it is in the last method) i need to get this done as soon as posible as its my homework and ive spent a long time on the logic and the codeing but im out of time its due at midnight and i still havent figured out this one problem.

Code:
using sc = System.Console;
using s = System;

public class statemant
{
	public static void Main()
	{
		string
			name,
			re1,
			re2,
			grade1,
			grade2,
			grade3;
		
		double
			reone,
			retwo,
			g1,
			g2,
			g3;

		double
			reA,
			avA,
			avB,
			avC,
			finalAvrage;


		sc.WriteLine("Please input your name:");
		name = sc.ReadLine();

		sc.WriteLine("In-put re-1:");
		re1 = sc.ReadLine();
		reone = s.Convert.ToDouble(re1);

		sc.WriteLine("In-put re-2:");
		re2 = sc.ReadLine();
		retwo = s.Convert.ToDouble(re2);


		sc.WriteLine("In-put grade1:");
		grade1 = sc.ReadLine();
		g1 = s.Convert.ToDouble(grade1);

		sc.WriteLine("In-put grade2:");
		grade2 = sc.ReadLine();
		g2 = s.Convert.ToDouble(grade2);

		sc.WriteLine("In-put grade3:");
		grade3 = sc.ReadLine();
		g3 = s.Convert.ToDouble(grade3);


		
		
		avA = av1(g1, g2);
		avB = av2(g2, g3);
		avC = av3(g1, g3);
		reA = re(reone, retwo);
		finalAvrage = final(reA, g1, g2, g3, avA, avB, avC);


		sc.WriteLine("Name: {0}  Class Avrage: {1}", name, finalAvrage);
		sc.WriteLine("research avrage {0}",reA);


		if( g3 < g1 && g2 > g3 || g3 < g1 && g2 == g3)//
		{
			sc.WriteLine("Grade1: {0}", g1);
			sc.WriteLine("Grade2: {0}", g2);
			sc.WriteLine("Avrage is {0}", avA);
			sc.ReadLine();
		}
		if( g1 < g2 && g3 > g1 || g1 < g2 && g3 == g1 )//
		{
			sc.WriteLine("Grade1: {0}", g2);
			sc.WriteLine("Grade2: {0}", g3);
			sc.WriteLine("Avrage is {0}", avB);
			sc.ReadLine();
		}
		if( g2 < g1 && g3 > g2 || g2 < g1 && g3 == g2 )//
		{
			sc.WriteLine("Grade1: {0}", g1);
			sc.WriteLine("Grade2: {0}", g3);
			sc.WriteLine("Avrage is {0}", avC);
			sc.ReadLine();
		}

		if( g2 == g1 && g3 == g2 )
		{
			sc.WriteLine("Grade1: {0}", g1);
			sc.WriteLine("Grade2: {0}", g2);
			sc.WriteLine("Avrage is {0}", avA);
			sc.ReadLine();
		}



	}

/*________________________________________
 * begin research avrage
 * _______________________________________*/

	public static double re(double reone, double retwo)
	{
		double avrage;
		avrage = (reone + retwo)/2;
		return avrage;
	}

/*______________________________________
 * end research avrage
 * ____________________________________*/





/*______________________________________________________________________________________
 * 
 * begin avrageing grades 1 - 3
 * _____________________________________________________________________________________
 * */
	public static double av1(double g1, double g2)
	{
		double avrage;
		avrage = (g1 + g2)/2;
		return avrage;
	}

	public static double av2(double g2, double g3)
	{
		double avrage;
		avrage = (g2 + g3)/2;
		return avrage;
	}

	public static double av3(double g1, double g3)
	{
		double avrage;
		avrage = (g1 + g3)/2;
		return avrage;
	}
/*________________________________________________________________________________
 * 
 * end grades 1-3 avrage
 * _______________________________________________________________________________*/

/* __________________________________________
 * final avrage
 * _________________________________________*/

	public static double final(double reA, double g1, double g2, double g3, double avA, double avB, double avC)
	{
		double 
			final1;
			//final2,
			//final3,
			//final4;

		if( g3 < g1 && g2 > g3 || g3 < g1 && g2 == g3)
		{
			final1 = (reA + avA)/2;
			//return final1;
		}
		if( g1 < g2 && g3 > g1 || g1 < g2 && g3 == g1 )
		{
			final1 = (reA + avB)/2;
			//return final2;
		}
		if( g2 < g1 && g3 > g2 || g2 < g1 && g3 == g2 )
		{
			final1 = (reA + avC)/2;
			//return final3;
		}
		if( g2 == g1 && g3 == g2 )
		{
			final1 = (reA + avA)/2;
			//return final4;
		}

		return final1 ;

	}
		






}
Damion is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 04-07-2007, 05:59 PM   #2 (permalink)
Registered User
 
Join Date: Aug 2005
Location: Ohio
Posts: 207
OS: VISTA


Re: C# unasighnd local variable?

I GOT IT!!!!! THANK GOD!!!!! thanks to every one who looked at it and at least tryed GLORY GLORY HALLY THINGY THAT I CANT SPELL!!!!!
Damion is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 05:52 AM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85