SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 305 Weeks Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 03 Dec 2017 My Price 10.00

Automobile class for a dealership fields for an ID number,

Practice homework assignment below. I have attached my current attempt. receiving errors. request assistance with if else statement to meet requirements below. for JAVA programming class, request commented

 

Create an Automobile class for a dealership. Include fields for an ID number, make, model, color, year, vin number, miles per gallon, and speed. Include get and set methods for each field. Do not allow the ID to be negative or more than 9999; if it is, set the ID to 0. Do not allow the year to be earlier than 2000 or later than 2017; if it is, set the year to 0. Do not allow the miles per gallon to be less than 10 or more than 60; if it is, set the miles per gallon to 0. Car speed should be initialized as 0. Include a constructor that accepts arguments for each field value and uses the set methods to assign the values. Also write two methods, Accelerate () and Brake (). Whenever Accelerate () is called, increase the speed by 5, and whenever Brake () is called, decrease the speed by 5. To allow users to specify the speed to increase (or decrease), create two overloading methods for Accelerate () and Brake () that accept a single parameter specifying the increasing (or decreasing) speed. Write an application that declares several Automobile objects and demonstrates that all the methods work correctly.

//---------------TestAutomobiles.java----------*/
import java.util.Scanner;
class TestAutomobiles
{
   public static void main (String[] args) //*throws java.lang.Exception*/
   {
   Automobile obj1=new Automobile(1,1964,45837,50,0,"CHEVY","Camaro","RED");
   System.out.println("-------------AUTOMOBILE 1-------------");
     System.out.println("AUTOMOBILE ID Number -            "+obj1.getID());
     System.out.println("AUTOMOBILE MAKE -                 "+obj1.getMake());
     System.out.println("AUTOMOBILE MODEL -                "+obj1.getModel());
     System.out.println("AUTOMOBILE COLOR -                "+obj1.getColor());
     System.out.println("AUTOMOBILE YEAR -                 "+obj1.getYear());
     System.out.println("AUTOMOBILE Vin Number -           "+obj1.getVin_number());
     System.out.println("AUTOMOBILE Miles per Gallon -     "+obj1.getMiles_p_gallon());
     System.out.println("AUTOMOBILE Current Speed -        "+obj1.getSpeed());
       obj1.Accelerate();
     System.out.println("AUTOMOBILE Accelerated Speed - "+obj1.getSpeed());
       obj1.Brake();
     System.out.println("AUTOMOBILE Speed after Brake - "+obj1.getSpeed());
  
     Automobile obj2=new Automobile(2,2012,38246,50,0,"FORD","F150","WHITE");
     System.out.println("-------------AUTOMOBILE 2-------------");
     System.out.println("AUTOMOBILE ID Number -            "+obj2.getID());
     System.out.println("AUTOMOBILE MAKE -                 "+obj2.getMake());
     System.out.println("AUTOMOBILE MODEL -                "+obj2.getModel());
     System.out.println("AUTOMOBILE COLOR -                "+obj2.getColor());
     System.out.println("AUTOMOBILE YEAR -                 "+obj2.getYear());
     System.out.println("AUTOMOBILE Vin Number -           "+obj2.getVin_number());
     System.out.println("AUTOMOBILE Miles per Gallon -     "+obj2.getMiles_p_gallon());
     System.out.println("AUTOMOBILE Current Speed -        "+obj2.getSpeed());
       obj1.Accelerate();
     System.out.println("AUTOMOBILE Accelerated Speed - "+obj2.getSpeed());
       obj1.Brake();
     System.out.println("AUTOMOBILE Speed after Brake - "+obj2.getSpeed());
   }


//---------------Automobile.java----------
//import java.util.Scanner;
class Automobile
{
//public:
int ID, year, vin_number, miles_p_gallon, speed;
String make, model, color;
Scanner scan = new Scanner( System.in );
Automobile()
{
ID=0;
year=0;
vin_number=0;
miles_p_gallon=0;
speed=0;
make= "NO MAKE";
model="NO MAKE";
color="NO MAKE";
}
Automobile(int id,int y,int vin_num,int m_p_g,int s, String mak,String mod,String col)
{
ID=setID(id);
year=setYear(y);
vin_number=vin_num;
miles_p_gallon=setMiles_p_gallon(m_p_g);
speed=s;
make=mak;
model=mod;
color=col;
}
int setID(int id)
{
    if(id>0||id<9999){
       System.out.print(0);
    }else{
    System.out.print(id);   

}
int setYear=(y);
{
    if(y<2000||y>2017){
System.out.println(0);
}else{
    System.out.println(y);
}
int getMiles_p_gallon=(m_p_g);
{
    if(m_p_g<10||m_p_g>60){
        Sytem.out.println(0);
    }else{
        System.out.println(mpg);

}
    {
    return id;
    return make;
    return model;
    return color;
    return year;
    return vin_number;
    return miles_p_gallon;
    return speed;
    speed+=5;
    speed-=5;
    int incSpeed;  speed+=incSpeed;
    int deSpeed;   speed-=deSpeed;
 
    }
}

   





Save the files as Automobile.java and TestAutomobiles.java.

Answers

(5)
Status NEW Posted 03 Dec 2017 07:12 AM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)