Saturday, February 6, 2010

[Java] lets discuss

 

Need help making a java program that calculates a parking fee based of the type of vehicle and how long it has been in the parking lot

Car $0.00/hour first 3 hours $1.50/hour after the first 3 hours
Truck $1.00/hour first 2 hours $2.50/hour after the first 2 hours
Bus $2.00/hour first hour $3.75/hour after the first hour

so far

I did this way 2 class pembaca.class and menuA.class

in menuA.class which is main()

import java.io.*;

class menuA

{

public static void main(String[] args) throws IOException
{

char menu;
int hourin=0, minutin=0, hourout=0, minutout=0;
Pembaca read = new Pembaca();

System.out.println("Please use capital letter");
System.out.print("Input b for Bus\n"
+"input c for car\n"
+"input t for Truck\n"
+"Type of Vehicle? =");
menu =' ';
menu = read.bacaChar();
while((menu!='C') && (menu!='T' )&& (menu!='B')) // validation rule for input...
{
System.out.print("Please key in Type of Vehicle That Listed above?\n");
menu = read.bacaChar();

}
System.out.println("Hour vehicle entered lot (0-23)? ");
hourin = read.bacaInt();
if( (hourin <0) && (hourin > 24) )
{
System.out.println("Please input value from 0 until 23 only, please giving the right

input?");
hourin = read.bacaInt();
}

System.out.println("Minute vehicle entered lot (0-59)?");
minutin = read.bacaInt();
if ( ( minutin < 0) && ( minutin > 60) )
{
System.out.println("Please input value from 0 until 59 only");
minutin=read.bacaInt();
}
System.out.println("Hour vehicle left lot (0-23)? ");
hourout = read.bacaInt();
}

if ( ( hourout < 0) && (hourout > 23) )
{
System.out.println("Please input value from 0 until 23 only");
hourout = read.bacaInt();
}
if (hourout < hourin)
{
System.out.println("please input bigger value then hour vehicle enter" );
hourout = read.bacaInt();
}

System.out.println("Minute vehicle left lot (0-59)?");
minutout = read.bacaInt();

if( (minutout < 0) && ( minutout > 60 ) )
{
System.out.println("Please input value from 0 until 59 only");
minutout = read.bacaInt();
}

int timeh = hourout - hourin;
int timem = minutin - minutout;

System.out.print("PARKING LOT CHARGE");

System.out.print("");

System.out.print("Type of vehicle: Car or Bus or Truck"+ menu) ;

System.out.print("TIME-IN "+hourin+":" + minutin);
System.out.print("TIME-OUT "+hourout+":"+ minutout);
System.out.print(" ----------------------------------");
System.out.print("PARKING TIME " + timeh + ":" + timem);
System.out.print("ROUNDED TOTAL : XX");
System.out.print(" ----------------------------------");
System.out.print("TOTAL CHARGE RM XX.XX");

}

} //main

} //class

please advise

the error..
C:\Users\ahazman\java\menuA.java:46: illegal start of type
if ( ( hourout < 0) && (hourout > 23) )
^
C:\Users\ahazman\java\menuA.java:46: illegal start of type
if ( ( hourout < 0) && (hourout > 23) )
^
C:\Users\ahazman\java\menuA.java:46: <identifier> expected
if ( ( hourout < 0) && (hourout > 23) )
^
C:\Users\ahazman\java\menuA.java:51: illegal start of type
if (hourout < hourin)
^
C:\Users\ahazman\java\menuA.java:51: > expected
if (hourout < hourin)
^
C:\Users\ahazman\java\menuA.java:57: <identifier> expected
System.out.println("Minute vehicle left lot (0-59)?");
^
C:\Users\ahazman\java\menuA.java:57: illegal start of type
System.out.println("Minute vehicle left lot (0-59)?");
^
C:\Users\ahazman\java\menuA.java:58: <identifier> expected
minutout = read.bacaInt();
^
C:\Users\ahazman\java\menuA.java:60: illegal start of type
if( (minutout < 0) && ( minutout > 60 ) )
^
C:\Users\ahazman\java\menuA.java:60: illegal start of type
if( (minutout < 0) && ( minutout > 60 ) )
^
C:\Users\ahazman\java\menuA.java:60: <identifier> expected
if( (minutout < 0) && ( minutout > 60 ) )
^
C:\Users\ahazman\java\menuA.java:71: <identifier> expected
System.out.print("PARKING LOT CHARGE");
^
C:\Users\ahazman\java\menuA.java:71: illegal start of type
System.out.print("PARKING LOT CHARGE");
^
C:\Users\ahazman\java\menuA.java:73: <identifier> expected
System.out.print("");
^
C:\Users\ahazman\java\menuA.java:73: illegal start of type
System.out.print("");
^
C:\Users\ahazman\java\menuA.java:75: <identifier> expected
System.out.print("Type of vehicle: Car or Bus or Truck"+ menu) ;
^
C:\Users\ahazman\java\menuA.java:75: illegal start of type
System.out.print("Type of vehicle: Car or Bus or Truck"+ menu) ;
^
C:\Users\ahazman\java\menuA.java:77: <identifier> expected
System.out.print("TIME-IN "+hourin+":" + minutin);
^
C:\Users\ahazman\java\menuA.java:77: illegal start of type
System.out.print("TIME-IN "+hourin+":" + minutin);
^
C:\Users\ahazman\java\menuA.java:78: <identifier> expected
System.out.print("TIME-OUT "+hourout+":"+ minutout);
^
C:\Users\ahazman\java\menuA.java:78: illegal start of type
System.out.print("TIME-OUT "+hourout+":"+ minutout);
^
C:\Users\ahazman\java\menuA.java:79: <identifier> expected
System.out.print(" ----------------------------------");
^
C:\Users\ahazman\java\menuA.java:79: illegal start of type
System.out.print(" ----------------------------------");
^
C:\Users\ahazman\java\menuA.java:80: <identifier> expected
System.out.print("PARKING TIME " + timeh + ":" + timem);
^
C:\Users\ahazman\java\menuA.java:80: illegal start of type
System.out.print("PARKING TIME " + timeh + ":" + timem);
^
C:\Users\ahazman\java\menuA.java:81: <identifier> expected
System.out.print("ROUNDED TOTAL : XX");
^
C:\Users\ahazman\java\menuA.java:81: illegal start of type
System.out.print("ROUNDED TOTAL : XX");
^
C:\Users\ahazman\java\menuA.java:82: <identifier> expected
System.out.print(" ----------------------------------");
^
C:\Users\ahazman\java\menuA.java:82: illegal start of type
System.out.print(" ----------------------------------");
^
C:\Users\ahazman\java\menuA.java:83: <identifier> expected
System.out.print("TOTAL CHARGE RM XX.XX");
^
C:\Users\ahazman\java\menuA.java:83: illegal start of type
System.out.print("TOTAL CHARGE RM XX.XX");
^
C:\Users\ahazman\java\menuA.java:87: class, interface, or enum expected
} //main
^
32 errors

Process completed.

even though system still can run... what is wrong?

__._,_.___
Visit http://aiaiai.com or http://jgame.org for more groups to join.
Java Official Group is created for the following topics: Java 2 Enterprise Edition - J2EE, Java 2 Standard Edition - J2SE, Java 2 Micro Edition - J2ME, XML, XSL, XSD, XPATH, Web Services, Jini, JXTA for all type of Java Geeks.
Whoever posts spam / ads / job related message will be BANNED IMMEDIATELY
.

__,_._,___

No comments:

Post a Comment