Given the following two programs, write the output of the CarValue class. public class Car { } private int modelYear; pr

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Given the following two programs, write the output of the CarValue class. public class Car { } private int modelYear; pr

Post by answerhappygod »

Given The Following Two Programs Write The Output Of The Carvalue Class Public Class Car Private Int Modelyear Pr 1
Given The Following Two Programs Write The Output Of The Carvalue Class Public Class Car Private Int Modelyear Pr 1 (166.96 KiB) Viewed 36 times
Given the following two programs, write the output of the CarValue class. public class Car { } private int modelYear; private double purchasePrice; public void setModel Year(int userYear){ model Year = userYear; } public int getModelYear() { return modelYear; } public void setPurchase Price(double userPrice){ purchase Price = userPrice; } public double getPurchasePrice() { return purchasePrice; } public void printInfo() { System.out.println("Car's information:"); System.out.println(" Model year: " + model Year); System.out.println(" Purchase price: $" + purchasePrice); } Put your answers in the answer area. public class CarValue { public static void main(String[] args) { Car myCar = new Car(); myCar.setModelYear(2018); myCar.setPurchase Price (30000); myCar.printlnfo(); Car anotherCar = new Car(); double price = myCar.getPurchase Price(); price = price* 1.2; anotherCar.setModel Year (2019); anotherCar.setPurchase Price (price); anotherCar.printlnfo();
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply