Asked by Jay
I am trying to finish this final problem on my Java homework. Due to a death in the family I've missed a class and now am trying to get back on track.
Write a driver class called GasPumpDriver that meets the following specifications:
• Prompt the user to enter a 16 digit credit card number, read as a string
• Prompt the user to enter a month/year from the credit card, in the format MM/YY, read as a string
• Prompt the user to enter a dollar amount to be spent on a gas purchase, read as a double
• Prompt the user to enter the price per gallon for unleaded gasoline, read as a double
• Prompt the user to enter the price per gallon for premium gasoline, read as a double
• Prompt the user to enter the price per gallon for super premium gasoline, read as a double
• Create a GasPump object.
• Call the set/insert methods with the dollar amounts.
• Call the “est” methods and print the values for:
o the number of unleaded gallons that can be purchased
o the number of premium gallons that can be purchased
o the number of super premium gallons that can be purchased
• Print the credit card information, in the following format, showing only the last 4 digits of the card number:
Card: XXXXXXXXXXXX1234 Month: 10 Year: 09
I was given this class which needs no changes:
public class GasPump {
private double unleadedPPG;
private double premiumPPG;
private double superPremiumPPG;
private double balance;
public GasPump() {
this.balance = 0.0;
}
public void setUnleadedPPG(double inPPG) {
this.unleadedPPG = inPPG;
}
public void setPremiumPPG(double inPPG) {
this.premiumPPG = inPPG;
}
public void setSuperPremiumPPG(double inPPG) {
this.superPremiumPPG = inPPG;
}
public void insert(double dollars) {
balance = balance + dollars;
}
public double estUnleadedGallons() {
return balance / unleadedPPG;
}
public double estPremiumGallons() {
return balance / premiumPPG;
}
public double estSuperPremiumGallons() {
return balance / superPremiumPPG;
}
Write a driver class called GasPumpDriver that meets the following specifications:
• Prompt the user to enter a 16 digit credit card number, read as a string
• Prompt the user to enter a month/year from the credit card, in the format MM/YY, read as a string
• Prompt the user to enter a dollar amount to be spent on a gas purchase, read as a double
• Prompt the user to enter the price per gallon for unleaded gasoline, read as a double
• Prompt the user to enter the price per gallon for premium gasoline, read as a double
• Prompt the user to enter the price per gallon for super premium gasoline, read as a double
• Create a GasPump object.
• Call the set/insert methods with the dollar amounts.
• Call the “est” methods and print the values for:
o the number of unleaded gallons that can be purchased
o the number of premium gallons that can be purchased
o the number of super premium gallons that can be purchased
• Print the credit card information, in the following format, showing only the last 4 digits of the card number:
Card: XXXXXXXXXXXX1234 Month: 10 Year: 09
I was given this class which needs no changes:
public class GasPump {
private double unleadedPPG;
private double premiumPPG;
private double superPremiumPPG;
private double balance;
public GasPump() {
this.balance = 0.0;
}
public void setUnleadedPPG(double inPPG) {
this.unleadedPPG = inPPG;
}
public void setPremiumPPG(double inPPG) {
this.premiumPPG = inPPG;
}
public void setSuperPremiumPPG(double inPPG) {
this.superPremiumPPG = inPPG;
}
public void insert(double dollars) {
balance = balance + dollars;
}
public double estUnleadedGallons() {
return balance / unleadedPPG;
}
public double estPremiumGallons() {
return balance / premiumPPG;
}
public double estSuperPremiumGallons() {
return balance / superPremiumPPG;
}
Answers
There are no human answers yet.
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.