7 Replies - 266 Views - Last Post: 06 June 2020 - 02:17 PM Rate Topic: -----

#1 Schiller   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-June 20

i attached my code of my attempt to the question i posted earlier.

Posted 06 June 2020 - 12:43 PM

public static void main(String[] args){

Scanner input = new Scanner (System.in);
String customerName; 
String postalAddress;
double economy = 29.99 ;
double midSize = 38.99;
double fullSize =43.50;
int duration;
double totalFee;


System.out.print("Enter the your name: ");

 customerName = input.nextLine();

System.out.print("Ennter postal address: ");

postalAddress = input.nextLine();
System.out.print("Ennter vehicle type: ");
economy = input.nextDouble();
System.out.print("Ennter vehicle type: ");
midSize = input.nextDouble();
System.out.print("Ennter vehicle type: ");
fullSize = input.nextDouble();



    


/*System.out.print("Enter rental fee; ");

 rentalFee = input.next();*/

System.out.print("Enter Duration: ");

duration = input.nextInt();
/*rentalFee = classification * duration; */
/*System.out.print("Enter total fee: ");

totalfee = input.nextInt();*/

System.out.println();

RentalCar rentalCar1 = new RentalCar(customerName,postalAddress , classification,rentalFee , duration, totalFee);        

RentalCar rentalCar2 = new RentalCar ();   
 

rentalCar1.print();     

rentalCar1.setclassification();
classification = input.next();
rentalCar1.setduration();
duration = input.next();

System.out.println();

rentalFee = rentalCar1.getduration() * rentalCar1.getclassification());

System.exit(0);

}

class RentalCar {

private

String customerName;

String postalAddress;

String classfication;

double rentalFee;

int Duration;

double totalFee;

public

RentalCar(){}

RentalCar(String customerName,String postalAddress , String classification, double rentalFee , int duration, double totalFee) {

customerName= customerName;

postalAddress = postalAddress;

classification = classification;

rentalFee = rentalFee;

duration = duration;

 totalFee =  totalFee;

}

public void print() {

System.out.println("Customer Name: " + customerName);

System.out.println("Postal Address: " + postalAddress);

System.out.println("Vehicle type: " + classfication);

System.out.println("Retal fee per day" + rentalFee);

System.out.println("total rental fee: " + totalFee);

}

public void settotalFee(double totalFee) {

totalFee= totalFee;

}

public double totalFee() {

return totalFee;

}

}

}

    
}



Is This A Good Question/Topic? 0
  • +

Replies To: i attached my code of my attempt to the question i posted earlier.

#2 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: i attached my code of my attempt to the question i posted earlier.

Posted 06 June 2020 - 01:05 PM

Do you have any questions?

Note: The posted code has lost all its formatting. Logically nested statements should be indented to show the logic. Please post properly indented code.

Also there is no class declaration or import statements for the code.
Was This Post Helpful? 0
  • +
  • -

#3 Schiller   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-June 20

Re: i attached my code of my attempt to the question i posted earlier.

Posted 06 June 2020 - 01:28 PM

View PostNormR, on 06 June 2020 - 01:05 PM, said:

Do you have any questions?

Note: The posted code has lost all its formatting. Logically nested statements should be indented to show the logic. Please post properly indented code.

Also there is no class declaration or import statements for the code.

Was This Post Helpful? 0
  • +
  • -

#4 Schiller   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-June 20

Re: i attached my code of my attempt to the question i posted earlier.

Posted 06 June 2020 - 01:35 PM

This is what am trying to solve.

Create a class named CarRental that contains fields that hold a renter’s name, postal address, size of the car rented, daily rental fee, length of rental in days, and total rental fee. The class contains a constructor that requires all the rental data except the daily rate and total fee, which are calculated based on the size of the car:
• economy at N$29.99 per day,
• midsize at N$38.99 per day,
• or full size at N$43.50 per day.
The class also includes a display() method that displays all the rental data. Create a subclass named LuxuryCarRental. This class sets the rental fee at N$79.99 per day and prompts the user to respond to the option of including a chauffeur at N$200 more per day. Override the parent class display() method to include chauffeur fee information. Write an application named UserCarRental that prompts the user for the data needed for a rental and creates an object of the correct type. Display the total rental fee. Save the files as CarRental.java, LuxuryCarRental.java, and UseCarRental.java.
Was This Post Helpful? 0
  • +
  • -

#5 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: i attached my code of my attempt to the question i posted earlier.

Posted 06 June 2020 - 01:39 PM

Do you have any specific questions about your assignment?

Can you fix the formatting of the posted code? The statements should not all start in first column.
Was This Post Helpful? 0
  • +
  • -

#6 Schiller   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-June 20

Re: i attached my code of my attempt to the question i posted earlier.

Posted 06 June 2020 - 01:42 PM

I am totally lost.
Was This Post Helpful? 0
  • +
  • -

#7 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: i attached my code of my attempt to the question i posted earlier.

Posted 06 June 2020 - 01:57 PM

Make a list of the assignment's requirements, and start with the first one.
What needs to be done to satisfy that requirement?
Get that part done before moving to the next item in the list.

Otherwise, ask your instructor for more help.

This post has been edited by NormR: 06 June 2020 - 02:28 PM

Was This Post Helpful? 0
  • +
  • -

#8 blackeagle123   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 124
  • Joined: 28-November 13

Re: i attached my code of my attempt to the question i posted earlier.

Posted 06 June 2020 - 02:17 PM

Something that might help i don't know if others agree with me (they know better i still have a lot to learn) but don't put everything in your main create a new class by right clicking on ur package start with creating the CarRental class
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1