Step 1 : Save the following code in CarPrice.java
package com.HomeworkLib;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class CarPrice {
// Method to calculate final price after
discount
public static double FinalPrice(double price, int
model) {
// Assign rate based on year
double discountRate = 0.05;
if(model <= 2000) {
discountRate =
0.2;
} else if(model <= 2010) {
discountRate =
0.1;
}
// Calculate new price and
return
return price * (1 -
discountRate);
}
public static void main(String[] args)
{
// Reader to get input
BufferedReader reader = new
BufferedReader(new InputStreamReader(System.in));
double beforeDiscount = 0;
double afterDiscount = 0;
String line = "";
String[] numbers;
double price;
double newPrice;
int year;
boolean run = true;
do {
System.out.print("Give the price and the year model of the car :
");
try {
line = reader.readLine();
numbers = line.trim().split(" ");
price = new Double(numbers[0].trim());
year = new Integer(numbers[1].trim());
// Find out price after discount
newPrice = FinalPrice(price, year);
System.out.println("The new price is " +
newPrice);
beforeDiscount += price;
afterDiscount += newPrice;
System.out.print("Another car? [n to stop] :
");
line = reader.readLine();
if("n".equals(line.trim().toLowerCase()))
{
run = false;
}
} catch
(Exception ex) {}
} while (run);
System.out.println("Total of prices
before discounting : " + beforeDiscount);
System.out.println("Total of prices
after discounting : " + afterDiscount);
}
}
Step 2 : Build the project and run the program using java com.HomeworkLib.CarPrice
Following is my sample output
java language using loops and methods public static double FinalPrice(double price, int model) • The method...
Some java questions: 18. Consider the following class definitions public class TestAB public static void main (String args) A bl new B() в ь2 -new B() ; b1.х, А.у, Ь2.х, в.у); System.out.printf ("%d, Sd, %d, d\n", class A public int x = 2; public static int y = 4; public A () ( X=y- class Bextends A public int x = 32; public static int y = 45; public B ( x ++y What is the result of attempting to...
C LANGUAGE. PLEASE INCLUDE COMMENTS :) >>>>TheCafe V2.c<<<< #include <stdio.h> int main() { int fries; // A flag denoting whether they want fries or not. char bacon; // A character for storing their bacon preference. double cost = 0.0; // The total cost of their meal, initialized to start at 0.0 int choice; // A variable new to version 2, choice is an int that will store the // user's menu choice. It will also serve as our loop control...
usion (24 points) Two firms are playing a repeated Bertrand game infinitely, each with the same marginal cost 100. The market demand function is P-400-Q. The firm who charges the lower price wins the whole market. When both firms charge the same price, each gets 1/2 of the total market. I. Coll A. (6 points) What price will they choose in the stage (only one period) Nash equilibrium? What price will they choose if in the stage game (only one...
need it as soo as posible please, thanks Macroeconmics received a 39 increase in your bominal wage and over the year, ination ran about 30) Suppose you received a Which of the following is nie? a) your nominal wage fell b) your real wage feil c) although your nominal wage fell your real waye d) both nominal and real wages increased 31) The actual rate of unemploy rate of employment will be greater than the naturale actual output in weater...
macroeconomic please solve it all i need help 8. If the price of coffee decreases, all else held coestant, the Law of Demand states that a firms will produce more coffee b. people will buy more coffee 9. If the price of coffee decreases, all else held constant, the Law of Supply states that a firms will produce more coffee b. people will buy more coffee e. firms will produce less coffee d people will buy more milk shakes c....
FART I TRUE FALSE QUESTIONS (10 points). Please write True (1) or False (F) on the blank Scarcity is the intimited nature of society's resources given society's limited wants 2. A reward is a type of positive incentive. 3. To remove difficulty of double coincidence of wants we use money. 4. An exogenous factor is a variable that can be controlled for inside the model. 5. The PPF will not have a constant slope. 6. The law of demand states...
FISCAL POLICY IN THEORY: March, 2020: we are on the verge of Congress and the President passing legislation that will empower the federal government to spend an unprecedented amount of EXTRA money not seen since World War 2 ---- in order to address the pandemic but also to help cushion the blow financially of perhaps ten or twenty million Americans --- or more --- losing their jobs, and thus suffering a drop in income. The scale of the 2020 recession...
I need Summary of this Paper i dont need long summary i need What methodology they used , what is the purpose of this paper and some conclusions and contributes of this paper. I need this for my Finishing Project so i need this ASAP please ( IN 1-2-3 HOURS PLEASE !!!) Budgetary Policy and Economic Growth Errol D'Souza The share of capital expenditures in government expenditures has been slipping and the tax reforms have not yet improved the income...
CASE 1-5 Financial Statement Ratio Computation Refer to Campbell Soup Company's financial Campbell Soup statements in Appendix A. Required: Compute the following ratios for Year 11. Liquidity ratios: Asset utilization ratios:* a. Current ratio n. Cash turnover b. Acid-test ratio 0. Accounts receivable turnover c. Days to sell inventory p. Inventory turnover d. Collection period 4. Working capital turnover Capital structure and solvency ratios: 1. Fixed assets turnover e. Total debt to total equity s. Total assets turnover f. Long-term...
do SWOT analysis. CASE 01 Mystic Monk Coffee connect . David L. Turnipseed University of South Alabama . wishing to donate to the monks' cause. Father Prior Daniel Mary did not have a great deal of experience in business matters but considered to what extent the monastery could rely on its Mystic Monk Coffee operations to fund the purchase of the ranch. If Mys- tic Monk Coffee was capable of making the vision a reality, what were the next steps...