Write a program to get details about a car and display it in core java Hint: Store the price in double. When displaying, display the price correct to 2 decimal places. Sample Input 1: Enter the car name: amaze Enter the car no: 3666 Enter the price: 870000.76 Sample Output 1: Car name:amaze Car no:3666 Price:870000.76 rs only Sample Input 2: Enter the car name: Swift Enter the car no: 7866 Enter the price: 550000 Sample Output 2: Car name:Swift Car no:7866 Price:550000.00 rs only
Answers
Answer:
Currently, the company is getting a bigger contribution of its overall sales from the metros.
“We are expecting to grow faster than the industry in this FY18-19 and expecting a double-digit growth this fiscal. With the second-generation Amaze, we are wishing to grow significantly in the tier 2 and tier 3 markets. The new Amaze will give considerably higher cumulative sales YoY compared to the outgoing Amaze model,” Rajesh Goel, senior vice-president & director - Marketing & Sales, Honda Cars India told ETAuto.
It is unlikely for the company to achieve its long-pinned 3 lakh units annual sales target this fiscal. “I wish to reach this target as soon as possible, but right now, I cannot give you a timeline,” Goel said.
Answer:
import java.util.*;
public class CarDetails
{
public static void main (String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the car name:");
String car_name = sc.nextLine();
System.out.println("Enter the car no:");
int car_no = sc.nextInt();
System.out.println("Enter the price:");
double car_price = sc.nextDouble();
System.out.println("Carname:"+car_name);
System.out.println("Carno:"+car_no);
System.out.printf("Price:%.2f rs only", car_price);
}
}
Explanation:
import java.util.*;
public class CarDetails
{
public static void main (String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the car name:");
String car_name = sc.nextLine();
System.out.println("Enter the car no:");
int car_no = sc.nextInt();
System.out.println("Enter the price:");
double car_price = sc.nextDouble();
System.out.println("Carname:"+car_name);
System.out.println("Carno:"+car_no);
System.out.printf("Price:%.2f rs only", car_price);
}
}