Complete this program to print a table of prices. The first column has width 8 and the second column has width 10. Print the prices with two digits after the decimal point.     import java.util.Scanner; public class Table{public static void main(String[] args){Scanner in = new Scanner(System.in);System.out.print("Unit price: ");double price = in.nextDouble(); System.out.println("Quantity Price");int quantity = 1; System.out.printf("%8d%n",quantity, (quantity * price) );quantity = 12;System.out.printf("%8d%n",quantity, (quantity * price));quantity = 100;System.out.printf("%8d%n",quantity, quantity * price);

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question

Complete this program to print a table of prices. The first column has width 8 and the second column has width 10. Print the prices with two digits after the decimal point.

 

 

import java.util.Scanner;

public class Table
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Unit price: ");
double price = in.nextDouble();

System.out.println("Quantity Price");
int quantity = 1;

System.out.printf("%8d%n",quantity, (quantity * price) );
quantity = 12;
System.out.printf("%8d%n",quantity, (quantity * price));
quantity = 100;
System.out.printf("%8d%n",quantity, quantity * price);

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning