Results 1 to 3 of 3
  1. #1
    MarcelCougar is offline Member
    Join Date
    Mar 2015
    Posts
    1
    Rep Power
    0

    Post I can't compile my java and in the cmd said that problem with the if else statement

    please help me. its for my assignment.

    import java.util.Scanner;
    import javax.swingJOptionPane;
    import java.io.*;

    public class CarRental
    {

    String name;
    int ic;
    int day;
    String carlist;
    int payment;
    String decision;
    int deposit;
    int costofcar;

    public void setDetail(String newName,int IC,int D,String newCar,String Dec,int Dep)
    {
    String name = newName;
    int ic = IC;
    int day = D;
    String carlist = newCar;
    String dec = Dec;
    int dep = Dep;
    }

    public void CalculatePayment()
    {
    payment = day * costofcar;
    }

    public void Carlist()
    {

    carlist[1]= new Car("Vellfire");
    carlist[2]= new Car("Swift");
    carlist[3]= new Car("Vios");
    carlist[4]= new Car("Myvi");
    }

    public void SelectionOfCar()
    {

    if( carlist == Vellfire)
    System.out.println("500 per day");
    System.out.println("200 for deposit");
    else if (carlist == Swift)
    System.out.println("200 per day");
    System.out.println("100 for deposit");
    else if(carlist == Vios)
    System.out.println("100 per day");
    System.out.println("50 for deposit");
    else(carlist == Myvi)
    System.out.println("80 per day");
    System.out.println("50 for deposit");
    }

    public void costofcar()
    {
    Vellfire = 500;
    Swift =200;
    Vios = 100;
    Myvi = 80;
    }

    public void DisplayInfo ()
    {
    System.out.println("============================== ==============================================");
    System.out.println("WELCOME TO COUGAR CAR RENTAL BERHAD");
    System.out.println("Name : "+name);
    System.out.println("I/C : "+ ic);
    System.out.println("Day of renting : "+day);
    System.out.println("Model of Car choosen : "+ modelofcar);
    System.out.println("Payment are : "+ payment);
    System.out.println("Proceed to rent ? (Yes/No) : "+ decision);
    System.out.println("Deposit you need to pay : "+deposit);
    System.out.println("Thank You for choosing us. Customer will always be our main priority.");
    System.out.println("============================== =============================================");
    }

    public static void main (String [] args)
    {
    Car One = new Car();
    One.setDetail("James",75963,5, "Myvi","Yes",50);
    One.CalculatePayment();
    One.Carlist();
    One.SelectionOfCar();
    One.costofcar();
    One.DisplayInfo();
    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: I can't compile my java and in the cmd said that problem with the if else statem

    Please go through BB Code List - Java Programming Forum - Learn Java Programming and edit your post accordingly.

    When seeking help with a compiler error, post the entire error message without paraphrasing.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: I can't compile my java and in the cmd said that problem with the if else statem

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 12
    Last Post: 10-20-2012, 06:55 PM
  2. Problem with compile Calendar
    By santunez in forum New To Java
    Replies: 1
    Last Post: 05-06-2010, 12:36 AM
  3. Compile problem when switching Java versions
    By siwelb in forum New To Java
    Replies: 2
    Last Post: 04-26-2010, 09:12 PM
  4. compile problem
    By chrisbremen in forum New To Java
    Replies: 8
    Last Post: 11-13-2008, 06:20 PM
  5. Problem with a switch statement in Java
    By baltimore in forum New To Java
    Replies: 2
    Last Post: 08-02-2007, 04:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •