SHARE
TWEET

Untitled

a guest Feb 27th, 2020 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Create public class CAR.  It should have:
  2.  
  3. 1.      Attributes: String NAME, float consumption, String  fuel,
  4.  
  5.  
  6.  
  7. 2.      Constructor with 3 parameters that will assign values to the appropriate attribute. For Fuel use: GASOLINE,  DIESEL and  GAS.
  8.  
  9.  
  10.  
  11. 3.      Methods getNAME() , getFUEL()– these method return the appropriate attribute value
  12.  
  13.  
  14.  
  15. 4.      Method  COST (int km)  that returns the amount of money you’ll need to buy fuel in order to pass distance of km kilometers, with the car that has fuel consumption of consumption  liters per kilometer and fuel that has some price per liter.
  16.  
  17. price:      If the car uses GASOLINE, the price= 69.50
  18.  
  19. If the car uses DISEL, the price= 57.50
  20.  
  21. If the car uses GAS, the price= 37
  22.  
  23. (Use the proportion)
  24.  
  25. КМ
  26.  
  27. Liters
  28.  
  29. X= (consumption * km) /100
  30.  
  31. //X- fuel liters for passing km kilometers
  32.  
  33.  
  34.  
  35. COST= X * price
  36.  
  37. 100
  38.  
  39. consumption
  40.  
  41. Km
  42.  
  43. X
  44.  
  45.  
  46.  
  47. In the main()  method of the public class
  48.  
  49. o   Create an array of 5 cars  
  50.  
  51. o   Create manual instance for every array element
  52.  
  53. o   Using the FOR loop, for every array element, display the name, fuel and car consumption
  54.  
  55. o   Find the car that will spent 800 km with least cost.  The output message should be similar to  this example:
  56.  
  57.  
  58.  
  59. You will pass 800 km with least money if you drive Citroen c1.
  60.  
  61. It will cost you 2350 den.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top