Need Help getting kinks out
From: CappaKia (HowaboutNO_at_spam.com)
Date: 12/13/04
- Next message: Grant Wagner: "Re: Sorting Algoithms History"
- Previous message: yourkit team: "Re: profiling software recomendation"
- Next in thread: Sebastian Scheid: "Re: Need Help getting kinks out"
- Reply: Sebastian Scheid: "Re: Need Help getting kinks out"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 13 Dec 2004 12:13:47 -0500
I'm almost finished with my project but I am getting error messages when I
compile. Can you help??
Here are the error messages that I am getting:
\My Documents\CS151\TicketDriver.java:121: '}' expected
}//end class TicketDriver
^
\Ticket.java:83: ')' expected
(Character.toUpperCase(this.response)==
(Character.toUpperCase(otherTicket.response))
^
\Ticket.java:90: ')' expected
}
^
\Ticket.java:91: illegal start of expression
}//end equals
^
4 errors
Tool completed with exit code 1
Here is a copy of my program:
* This class inputs the speeders info, calculates and
* outputs.
*
********************************************************************************************/
import java.text.DecimalFormat;
public class Ticket
{
public String name; //Input driver's name
private int speed; //Input driver's speed
private int speedLimit; //Input of speed limit
private double fine; //Calculates fine Amount
private char response; //Input of whether driving in school zone
//********************************************************************************************
//This constructor assigns values into insatnce variables
public Ticket(String name, int speed, int speedLimit, char response)
{
this.name = name;
this.speed = speed;
this.speedLimit = speedLimit;
this.response = response;
} // end Ticket constructor
//*********************************************************************************************
//
public Ticket (String name, int speedLimit)
{
this.name = name;
this.speedLimit = speedLimit;
}//end Ticket constructor
//********************************************************************************************
//This method inputs
public Ticket()
{
System.out.print("Enter driver's name: ");
name = Input.readLine ();
System.out.print("Enter driver's speed: ");
speed = Input.readInt ();
while (speed > 100)
{
System.out.println("Number of hours illegal");
System.out.print("Please enter correct number of hours:");
speed = Input.readInt();
}
System.out.print("Was driver in school zone during school hours? Y or N:
");
response = Input.readChar ();
System.out.print("Enter speed limit: ");
speedLimit = Input.readInt ();
}//end Drivers Information
//********************************************************************************************
//Make Copy
public Ticket makeCopy()
{
Ticket ticket = new Ticket();
ticket.name = this.name;
ticket.speed = this.speed;
ticket.speedLimit = this.speedLimit;
ticket.response = this.response;
return ticket;
} // end makeCopy
//*********************************************************************************************
//This method checks to see if any of the car drivers have the same
information
public boolean equals (Ticket otherTicket)
{
if ((this.name.equalsIgnoreCase(otherTicket.name)) &&
(this.speed == (otherTicket.speed))&&
(this.speedLimit == (otherTicket.speedLimit)) &&
(Character.toUpperCase(this.response)==
(Character.toUpperCase(otherTicket.response))
{
return true;
}
else
{
return false;
}
}//end equals
//***********************************************************************************************
//This method calculates the fine
public void fine()
{
int overSpeed;
overSpeed = speed - speedLimit;
if(overSpeed > 10)
{
fine = overSpeed * 10;
}
else
{
fine = overSpeed * 6;
}
}// end Calculate Fine
//*********************************************************************************************
//This method is the input validation
public void schoolZone ()
{
if(response == 'y' || response == 'Y')
{
fine = fine * 2;
}
//else
//{
// System.out.println("Invalid Entry");
// System.out.println("You entered" + response +"Please enter a Y for
Yes or N for No: ");
//}
}//end school zone
//********************************************************************************************
//This method prints the table heading
public void tableHeading ()
{
System.out.println("Name" + '\t'+'\t' + "Speed" + '\t' + "SpeedLimit" +
'\t' + "SchoolZone" +
'\t' + "Fine");
}// end tableheading
//********************************************************************************************
//This method prints the output
public void tableData ()
{
DecimalFormat currencyFormat = new DecimalFormat ("$, ##0.00");
System.out.println(name + '\t'+" " + speed + '\t' + speedLimit + '\t'
+ '\t' + response + '\t' +
'\t' + currencyFormat.format(fine));
}// end tableData
//*******************************************************************************************
//This method returns the name of the driver
public String getName()
{
return name;
} //end getName
//******************************************************************************************
//This method returns the speed
public int getSpeed()
{
return speed;
} //end getSpeed
//******************************************************************************************
//This method returns the speed limit
public int getSpeedLimit()
{
return speedLimit;
} // end getSpeedLimit
//******************************************************************************************
//This method returns the response
public char getResponse()
{
return response;
} // end getresponse
//******************************************************************************************
//This method returns the fine
public double getFine()
{
return fine;
} // end getfine
//******************************************************************************************
//This method changes the name
public void setName(String dName)
{
name = dName;
} //end setName
//********************************************************************************************
//This method changes the speed
public void setSpeed(int dSpeed)
{
speed = dSpeed;
} //end setSpeed
//*******************************************************************************************
//This method changes the speed limit
public void setSpeedLimit(int cSpeedLimit)
{
speedLimit = cSpeedLimit;
} //end setspeedLimit
//********************************************************************************************
//This method changes the response
public void setResponse(char cResponse)
{
response = cResponse;
} //end setresponse
//*********************************************************************************************
// This method changes all of the variables
public void setALL(String dName, int dSpeed, int cSpeedLimit, char
cResponse)
{
name = dName;
speed = dSpeed;
speedLimit = cSpeedLimit;
response = cResponse;
}//end SetALL
}//end class Ticket
//**********************************************************************************************
- Next message: Grant Wagner: "Re: Sorting Algoithms History"
- Previous message: yourkit team: "Re: profiling software recomendation"
- Next in thread: Sebastian Scheid: "Re: Need Help getting kinks out"
- Reply: Sebastian Scheid: "Re: Need Help getting kinks out"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|