Fix the code Make it look like the expect
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Fix the code
Make it look like the expect

Transcribed Image Text:Expected
one 11
is 674.991000 Enter the product name: Enter the price: Enter a discount percentage: The price of iPhone 11 is $749.99.
The discount price for iPhone 11 is $674.99.
Expected
Phone 11 Pro Max
is 1062.491500 Enter the product name: Enter the price: Enter a discount percentage: The price of iPhone 11 Pro Max is
The discount price for iPhone 11 Pro Max is $1062.49.
![14
public static void main(String[] args)
{
// Step 3: Create a Scanner object to read input
//
15
16
17
from the keyboard
18
Scanner sc = new Scanner(System.in);
19
// Step 4: Ask for the product name with prompt
"Enter the product name:
System.out.print("Enter the product name: ");
20
21
//
22
23
// Step 5: Read the name of a product from the keyboard
The product name could have multiple words
24
25
//
26
String str = sc.nextLine();
27
// Step 6: Trim spaces from both ends of the name
str.trim();
28
29
30
// Step 7: Ask for the product price with prompt
"Enter the price: "
System.out.print("Enter the price: ");
31
32
//
33
34
// Step 8: Read a double number as the price of the product
double price = sc.nextDouble();
35
36
37
// Step 9: Ask for the discount percentage with prompt
"Enter a discount percentage:
System.out.print("Enter a discount percentage");
38
39
//
40
41
// Step 10: Read a double number as the discount percentage
// For example, 0.1 for 10% and 0.15 for 15%.
double discount = sc.nextDouble();
42
43
44
45
// Step 11: Display the price of the product with a dollar sign
//
// Sample output:
// The price of iPhone 11 is $749.99.
46
47
and two decimal digits
48
49
50
51
double discount_price = price*(1-discount);
52
53
// Step 12: Display the discount price of the product with
54
//
// The discount price = price * (1 - discount_percentage)
// Sample output:
// The discount price for iPhone 11 is $674.99.
System.out.print("The discount price of "+str+" is "+String.format("%2f", discount_price));
a dollar sign and two decimal digits
55
56
57
58
50](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F170cb9b5-2292-4ecc-9f24-3c60291ff66d%2F86408213-814a-4a7e-89d4-8a4a0ea080d6%2Fg0tada_processed.jpeg&w=3840&q=75)
Transcribed Image Text:14
public static void main(String[] args)
{
// Step 3: Create a Scanner object to read input
//
15
16
17
from the keyboard
18
Scanner sc = new Scanner(System.in);
19
// Step 4: Ask for the product name with prompt
"Enter the product name:
System.out.print("Enter the product name: ");
20
21
//
22
23
// Step 5: Read the name of a product from the keyboard
The product name could have multiple words
24
25
//
26
String str = sc.nextLine();
27
// Step 6: Trim spaces from both ends of the name
str.trim();
28
29
30
// Step 7: Ask for the product price with prompt
"Enter the price: "
System.out.print("Enter the price: ");
31
32
//
33
34
// Step 8: Read a double number as the price of the product
double price = sc.nextDouble();
35
36
37
// Step 9: Ask for the discount percentage with prompt
"Enter a discount percentage:
System.out.print("Enter a discount percentage");
38
39
//
40
41
// Step 10: Read a double number as the discount percentage
// For example, 0.1 for 10% and 0.15 for 15%.
double discount = sc.nextDouble();
42
43
44
45
// Step 11: Display the price of the product with a dollar sign
//
// Sample output:
// The price of iPhone 11 is $749.99.
46
47
and two decimal digits
48
49
50
51
double discount_price = price*(1-discount);
52
53
// Step 12: Display the discount price of the product with
54
//
// The discount price = price * (1 - discount_percentage)
// Sample output:
// The discount price for iPhone 11 is $674.99.
System.out.print("The discount price of "+str+" is "+String.format("%2f", discount_price));
a dollar sign and two decimal digits
55
56
57
58
50
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 3 images

Knowledge Booster
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.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education