Create a class Car and make any three methods?class should have variable and constructor?
package webprograms;
import java.util.Scanner;
/**
Create a class Car and make any three methods? class should have variable and constructor?
*/
public class car
{
public int speed;
public int price;
public String model;
public car() {
this.speed =0;
this.price = 0;
this.model = "";
}
public car(int speed) {
this.speed = speed;
this.price = 0;
this.model = "";
}
public car(int speed, int price) {
this.speed = speed;
this.price = price;
this.model = "";
}
public car(int speed, int price, String model) {
this.speed = speed;
this.price = price;
this.model = model;
}
void Speed()
{
Scanner input=new Scanner(System.in);
System.out.println("Enter Speed");
this.speed=input.nextInt();
System.out.println("Speed is "+this.speed);
}
void Price()
{
Scanner input=new Scanner(System.in);
System.out.println("Enter Price");
this.price=input.nextInt();
System.out.println("Price is "+this.price);
}
void Model()
{
Scanner input=new Scanner(System.in);
System.out.println("Enter Model");
this.model=input.next();
System.out.println("Model is "+this.model);
}
}
1 Comments
Thanks A Lord For Publish In Your Blog, This Is A Great Things To Learned Many Information. Keep Posting Many Blogs Like This.
ReplyDeleteWeb portal development company in chennai, Web portal development services in chennai
Your Comment is Submitted