I don't understand this

  • Thread starter Thread starter Robert Blackwell
  • Start date Start date
R

Robert Blackwell

I'm trying to follow along in class typing exactly whats put on the board.

using System;

namespace SchoolStuff

{


public class UseCalcPay

{

public static void Main()

{

double myHours = 37.5;

double myRate = 12.75;

double grossPay;

grosspPay = CalcPay(myHours, myRate);

Console.WriteLine("My gross pay is{0}", grossPay.ToString("C"));

}

public static double CalcPay(double hours, double rate)

{

double gross;

gross = hours * rate;

return gross;

}

}

}

And when I try to compile, it saysit can't find the name grossPay

Then, on this



using System;

namespace SchoolStuff

{


public class UseSevenPercentSalesTax

{

public static void Main()

{

double myPurchase = 10.99;

ComputeSevenPercentSalesTax(myPurchase);

ComputeSevenPercentSalesTax(35.67);

{

double tax;

tax = SaleAmount * 0.07;

Console.WriteLine("The tax on {0} is {1}", SaleAmount, tax.ToString("f"));

}

}

}



it's expecting a brace but I dn't know where



Lastly on this example

using System;

namespace SchoolStuff

{


public class UseSalesTax

{

public static void Main()

{

double myPurchase = 239.11;

double myRate = 0.10;

ComputeSalesTax(myPurchase, myRate);

ComputeSalesTax(16.55, 0.02);

}

public static ComputeSalesTax(double saleAmount, double taxRate)

{

double tax;

tax = saleAmount * taxRate;

Console.WriteLine("The tax on {0} is {1}", saleAmount, tax.ToString("F"));

}

}

}

it says it has to return a type.

I asked the teacher but he's like..oh yeah..fjkslf mumble mumble mumble
seriously, he can't answer...I'm not even sure he knows very much about C#
because he didn't know what a name space is and it seems as if he's just
reading the book one chapter ahead or something.

Please help if you can.
 
Robert,
grosspPay = CalcPay(myHours, myRate);
And when I try to compile, it saysit can't find the name
grossPay

Look closely. It can't find grosspPay (note the extra "p"). Change
it to grossPay and it will work.

Then, on this

using System;

namespace SchoolStuff
{
public class UseSevenPercentSalesTax
{
public static void Main()
{
double myPurchase = 10.99;
ComputeSevenPercentSalesTax(myPurchase);
ComputeSevenPercentSalesTax(35.67);
{ // *** Delete this brace. ***
double tax;
tax = SaleAmount * 0.07;
Console.WriteLine("The tax on {0} is {1}", SaleAmount,
tax.ToString("f"));
}
}
}

it's expecting a brace but I dn't know where


it says it has to return a type.

I asked the teacher but he's like..oh yeah..fjkslf mumble mumble
mumble seriously, he can't answer...I'm not even sure he knows
very much about C# because he didn't know what a name space is
and it seems as if he's just reading the book one chapter ahead
or something.

Change this:

public static ComputeSalesTax(double saleAmount, double taxRate)

to this:

public static double ComputeSalesTax(double saleAmount, double
taxRate)


On a side note...

If possible, please try to use something other than Outlook Express
to post messages containing code. Outlook really mangles the code,
which makes it hard to read.

Hope this helps.

Chris.
 
Robert Blackwell said:
I'm trying to follow along in class typing exactly whats put on the board.

using System;

namespace SchoolStuff

{


public class UseCalcPay

{

public static void Main()

{

double myHours = 37.5;

double myRate = 12.75;

double grossPay;

grosspPay = CalcPay(myHours, myRate); /* Here is the problem grosspPay should be grossPay */

Console.WriteLine("My gross pay is{0}", grossPay.ToString("C"));

}

public static double CalcPay(double hours, double rate)

{

double gross;

gross = hours * rate;

return gross;

}

}

}

And when I try to compile, it saysit can't find the name grossPay

Then, on this



using System;

namespace SchoolStuff

{


public class UseSevenPercentSalesTax

{

public static void Main()

{

double myPurchase = 10.99;

ComputeSevenPercentSalesTax(myPurchase);
/* Here I presume that you are trying to invoke ComputeSevenPercentSalesTax function, but where is this function declared ?? */
 
Sorry about the code pasting...normally I past from VS into my chat client or a web based text box, then cut and past into here and it's normal text etc.

Thanks helping me out. I beat myself up mentally when I can't find what
s wrong...I don't think I would have caught the extra p.
ComputeSevenPercentSalesTax(myPurchase);
/* Here I presume that you are trying to invoke ComputeSevenPercentSalesTax function, but where is this function declared ?? */

That's what I was thinking...unless I missed it, I don't think he even got to that part.
But actually, that's probably why I had that lone brace there...cause I was gonna put that function before it or something.


PS. How did you guys learn to program? Through a course at school, or self taught with books and or help from friends.

The teacher mumbles a lot and often doesn't complete his sentances and it seems as if he's only a chapter or so ahead of the class cause he couldn't asnwer many of the questions that other classmates asked.

I was assuming that the teacher would be an "experienced" professional or something; being that this is a college course. Is that the way a lot of beginner programming classes are?
 
PS. How did you guys learn to program? Through a course at
school, or self taught with books and or help from friends.

Robert,

I'm largely self-taught, and prefer to learn from books rather than
taking classes. I think both ways are good ways to learn, so long as
the learning resources (teachers and books) are of high quality.
The teacher mumbles a lot and often doesn't complete his
sentances and it seems as if he's only a chapter or so ahead of
the class cause he couldn't asnwer many of the questions that
other classmates asked.

I was assuming that the teacher would be an "experienced"
professional or something; being that this is a college course.
Is that the way a lot of beginner programming classes are?

I don't think (hope?) the situation you're in is the norm. But I
have been in exactly the same situation before. My solution was to
get an introductory text and teach myself.

That happened to me before the world wide web had been invented.
Today, you can just surf the web and get introductory material on C#:

http://www.codeguru.com/csharp/
http://www.c-sharpcorner.com/
http://www.csharphelp.com/
http://www.csharp-station.com/Tutorial.aspx
http://www.aewnet.com/root/dotnet/csharp/csharptutorials/
http://www.hitmill.com/programming/dotNET/csharp.html#tutorials



Chris.
 
Back
Top