1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
yulyashka [42]
3 years ago
13

Create a class named CarRental that contains fields that hold a renter's name, zip code, size of the car rented, daily rental fe

e, 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 bades on the sice of the car; economy at $29.99 per day, midsize at 38.99$ per day, or full size at 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 $79.99 per day and prompts the user to respond to the option of including a chauffer at $200 more per day. Override the parent class display() method to include chauffer fee information. Write an application named UseCarRental 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, LuxaryCarRental.java, and UseCarRental.java.
Here is my code:

package CarRental;
public class CarRental
{
String name;
int zipcode;
String size;
double dFee;
int days;
double total;

public String getName()
{
return name;
}
public int getZipcode()
{
return zipcode;
}
public String getSize()
{
return size;
}
public int getDays()
{
return days;
}
public CarRental(String size)
{
if(size.charAt(0)=='m')
dFee = 38.99;
else
if(size.charAt(0)=='f')
dFee = 43.50;
else
dFee = 29.99;
}
public void calculateTotal(int days)
{
total = dFee*days;
}
public void print()
{
System.out.println("Your rental total cost is: $" + total);
}

}

package CarRental;
import java.util.*;
public class LuxaryCarRental extends CarRental
{
public LuxaryCarRental(String size, int days)
{
super(size);
}
public void CalculateTotalN()
{
super.calculateTotal(days);
dFee = 79.99;

int chauffer;
Scanner keyboard = new Scanner(System.in);
System.out.println("Do you want to add a chauffer for $200? Enter 0 for"
+ " yes and 1 for no");
chauffer = keyboard.nextInt();

if(chauffer!=1)
total = dFee;
else
total = dFee + 100;
}
}

package CarRental;
import java.util.*;
public class UseCarRental
{
public static void main(String args[])
{
String name, size;
int zipcode, days;

Scanner keyboard = new Scanner(System.in);

System.out.println("Enter total days you plan on renting: ");
days = keyboard.nextInt();

System.out.println("Enter your name: ");
name = keyboard.next();

System.out.println("Enter your billing zipcode: ");
zipcode = keyboard.nextInt();

System.out.println("Enter the size of the car: ");
size = keyboard.next();

CarRental economy = new CarRental(size);
economy.calculateTotal(days);
economy.print();

LuxaryCarRental fullsize = new LuxaryCarRental(size, days);
fullsize.CalculateTotalN();
fullsize.print();

}

Computers and Technology
1 answer:
Anarel [89]3 years ago
4 0

Answer:

Here is the corrected code: The screenshot of the program along with its output is attached. The comments are written with each line of the program for better understanding of the code.

CarRental.java

public class CarRental  {  //class name

//below are the data members name, zipcode, size, dFee, days and total

String name;  

int zipcode;

String size;

double dFee;

int days;

double total;  

public String getName()  {  //accessor method to get the name

return name; }

public int getZipcode()  { //accessor method to get the zipcode

return zipcode; }

public String getSize() {  //accessor method to get the size

return size; }

public int getDays() {  //accessor method to get the days

return days;  }

public CarRental(String size)  {  //constructor of CarRental class

if(size.charAt(0)=='e')  // checks if the first element (at 0th index) of size data member is e

     dFee = 29.99;  // sets the dFee to 29.99

  else if(size.charAt(0)=='m')  // checks if the first element (at 0th index) of size data member is m

     dFee = 38.99;  // sets the dFee to 38.99

  else   // checks if the first element (at 0th index) of size data member is f

     dFee =43.50;  // sets the dFee to 43.50

   }

public void calculateTotal(int days) {  //method calculateTotal of CarRental

total = dFee*days;  }  //computes the rental fee

public void print()   {  //method to display the total rental fee

System.out.println("Your rental total cost is: $" + total);  } }

Explanation:

LuxuryCarRental.java

import java.util.*;

public class LuxuryCarRental extends CarRental {  //class LuxuryCarRental that is derived from class CarRental

public LuxuryCarRental(String size, int days) {  // constructor of LuxuryCarRental

super(size);}   //used when a LuxuryCarRental class and CarRental  class has same data members i.e. size

public void calculateTotal() {  //overridden method

super.calculateTotal(days); // used because CarRental  and LuxuryCarRental class have same named method i.e.  calculateTotal

dFee = 79.99;  //sets the rental fee at $79.99 per day

total = dFee;  }  //sets total to rental fee value

public void print(){  //overridden method

   int chauffeur;  // to decide to include chauffeur

Scanner keyboard = new Scanner(System.in);  //used to take input from user

System.out.println("Do you want to add a chauffeur for $200? Enter 0 for"

+ " yes and 1 for no");  // prompts the user to respond to the option of including a chauffeur at $200 more per day

chauffeur = keyboard.nextInt();   //reads the input option of chauffeur from user

if(chauffeur==1)  //if user enters 1 which means user does not want to add a chauffeur

total = dFee;  //then set the value of dFee i.e.  $79.99  to total

else  //if user enters 0 which means user wants to add a chauffeur

total = dFee + 200;  //adds 200 to dFee value and assign the resultant value to total variable

System.out.println("Your rental total cost is: $" + total);  }  } //display the total rental fee

UseCarRental.java

import java.util.*;

public class UseCarRental{ //class name

public static void main(String[] args){ //start of main() function body

String name, size; // declare variables

int zipcode, days; //declare variables

Scanner keyboard = new Scanner(System.in); // to take input from user

System.out.println("Enter total days you plan on renting: "); //prompts user to enter total days of rent

days = keyboard.nextInt(); // reads value of days from user

System.out.println("Enter your name: "); //prompts user to enter name

name = keyboard.next(); //reads input name from user

System.out.println("Enter your billing zipcode: "); // prompts user to enter zipcode

zipcode = keyboard.nextInt(); //reads input zipcode from user

System.out.println("Enter the size of the car: "); // prompts user to enter the value of size

size = keyboard.next(); //reads input size from user

CarRental economy = new CarRental(size); //creates an object i.e. economy of class CarRental

economy.calculateTotal(days); //calls calculateTotal method of CarRental using instance economy

economy.print(); //calls print() method of CarRental using instance economy

LuxuryCarRental fullsize = new LuxuryCarRental(size, days);  //creates an object i.e. fullsize of class LuxuryCarRental

fullsize.calculateTotal();  //calls calculateTotal method of LuxuryCarRental using instance fullsize

fullsize.print(); }} //calls print() method of LuxuryCarRental using instance fullsize      

You might be interested in
When looking to ensure your website is easily accessible by mobile users, what should you focus on doing first
antoniya [11.8K]

Answer:

There are may steps in this procedure but there few steps that do first to access your mobile with your website.

Explanation:

When we are looking in our website and easily accessed by the mobile users, It is easy for them.

There are certain steps that should do first.

  • First step is that you have to redesign the website color scheme
  • To optimize your website
  • To create the mobile app
  • Now to shorten the content in website.

6 0
3 years ago
FIND THE 6 ERRORS IN THIS RESUME 30 POINTS!!!!
babymother [125]
Answer:
________________________
The following is a list of "6 (six) errors" :
__________________________________
1)  The "city, state, and zip code" should be listed on a separate line, directly following the street address:
_______________________________________________________
   → Hartford, CT 06114
_______________________________________________________
2)  In "Objective" section:  The misspelled:  "challenging" should be changed to "challenging".
_______________________________________________________
3) In the "Objective" section:  The word:  "righting" should be changed to:
      "writing".
_______________________________________________________
4)  In the "Summary" section:  The misspelled: "addjust" should be changed to:   "adjust" .
________________________________________________________
5)  The misspelled "impppeccable" should be changed to "impeccable".
________________________________________________________
6)  Perhaps, "drive-thru" should be changed to: "drive-through" ;  but even more importantly— refer to:
________________________________________________________
"Managed all staff and ensured hi performance and efficiency" ;
          → The "hi" should be changed to "high".
___________________________________________________
These are some errors.  Glad to be of help!
___________________________________________________
6 0
3 years ago
What did the Lorax mean when he said i speak for the trees
kirill [66]

Answer:

The trees have no tongues, And the Lorax disapproves of the use of the Tree and the Thneed.

3 0
3 years ago
100 POINTS!!!!!!
Veronika [31]

Answer:

The fundamental limitation of symmetric (secret key) encryption is ... how do two parties (we may as well assume they are Alice and Bob) agree on a key? In order for Alice and Bob to communicate securely they need to agree on a secret key. In order to agree on a secret key, they need to be able to communicate securely. In terms of the pillars of IA, To provide CONFIDENTIALITY, a secret key must first be shared. But to initially share the key, you must already have CONFIDENTIALITY. It's a whole chicken-and-egg problem.

This problem is especially common in the digital age. We constantly end up at websites with whom we decide we want to communicate securely (like online stores) but with whom we there is not really an option to communicate "offline" to agree on some kind of secret key. In fact, it's usually all done automatically browser-to-server, and for the browser and server there's not even a concept of "offline" — they only exist online. We need to be able to establish secure communications over an insecure channel. Symmetric (secret key) encryption can't do this for us.

Asymmetric (Public-key) Encryption

Yet one more reason I'm barred from speaking at crypto conferences.

xkcd.com/177/In asymmetric (public key) cryptography, both communicating parties (i.e. both Alice and Bob) have two keys of their own — just to be clear, that's four keys total. Each party has their own public key, which they share with the world, and their own private key which they ... well, which they keep private, of course but, more than that, which they keep as a closely guarded secret. The magic of public key cryptography is that a message encrypted with the public key can only be decrypted with the private key. Alice will encrypt her message with Bob's public key, and even though Eve knows she used Bob's public key, and even though Eve knows Bob's public key herself, she is unable to decrypt the message. Only Bob, using his secret key, can decrypt the message ... assuming he's kept it secret, of course.

Explanation:

3 0
2 years ago
Which of the following can be used to locate data in a particular column?
dangina [55]

Answer:

A. VLOOKUP

Explanation:

VLOOKUP is an Excel function to look up data in a table organized vertically. VLOOKUP supports approximate and exact matching, and wildcards (* ?) for partial matches. Lookup values must appear in the first column of the table passed into VLOOKUP.

Purpose 

Lookup a value in a table by matching on the first column

Return value 

The matched value from a table.

Syntax 

=VLOOKUP (value, table, col_index, [range_lookup])

Arguments 

value - The value to look for in the first column of a table.

table - The table from which to retrieve a value.

col_index - The column in the table from which to retrieve a value.

range_lookup - [optional] TRUE = approximate match (default). FALSE = exact match.

4 0
2 years ago
Other questions:
  • Desktop, laptop, and tablet computers, and mobile devices are classified as _______.
    7·1 answer
  • what is a massive online storage that allows for access by any Internet connected device running a web browser and is used for l
    7·1 answer
  • Clep allows students to do all of thw following except which?
    11·2 answers
  • Constraints are a. quantities to be minimized in a linear programming model. b. quantities to be maximized in a linear programmi
    5·1 answer
  • What year did buck tooth bob become famous
    11·2 answers
  • Which of the following is constantly changing and advancing?
    11·1 answer
  • When an external device becomes ready to be serviced by the processor the device sends a(n)_________ signal to the processor.
    8·1 answer
  • What would the internet be like today if there was no World Wide Web?
    9·1 answer
  • After data is collected, how is it analyzed?
    10·1 answer
  • Why is it important to continiously conduct penetration testing for a strong security system?.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!