/** * A Java application to input the name and price of * a product, and a discount percentage, then compute * and display the discount price. * * Step 2: Enter your name for @author and today's date for @version * @author * @version */ public class DiscountPrice public static void main(String [] args) { // Step 3: Create a Scanner object to read input // from the keyboard // Step 4: Ask for the product name with prompt // "Enter the product name: " // Step 5: Read the name of a product from the keyboard The product name could have multiple words // // Step 6: Trim spaces from both ends of the name // Step 7: Ask for the product price with prompt // "Enter the price: " // Step 8: Read a double number as the price of the product // Step 9: Ask for the discount percentage with prompt "Enter a discount percentage: // // Step 10: Read a double number as the discount percentage · // For example, 0.1 for 10% and 0.15 for 15%.

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
icon
Related questions
Question
1
// Step 1: Impórt Jávà člášs Scanner
2
/**
* A Java application to input the name and price of
* a product, and a discount percentage, then compute
* and display the discount price.
4
6.
7
* Step 2: Enter your name for @author and today's date for @version
* @author
* @version
8
9.
10
11
*/
public class DiscountPrice
{
12
13
14
public static void main(String [] args)
15
// Step 3: Create a Scanner object to read input
from the keyboard
16
17
//
18
19
20
// Step 4: Ask for the product name with prompt
21
//
"Enter the product name: "
22
23
24
// Step 5: Read the name of a product from the keyboard
25
//
The product name could have multiple words
26
27
28
// Step 6: Trim spaces from both ends of the name
29
30
31
// Step 7: Ask for the product price with prompt
32
//
"Enter the price: "
33
34
35
// Step 8: Read a double number as the price of the product
36
37
38
// Step 9: Ask for the discount percentage with prompt
39
//
"Enter a discount percentage:
40
41
42
// Step 10: Read a double number as the discount percentage ·
// For example, 0.1 for 10% and 0. 15 for 15%.
43
44
O Restricted Mode
O 0 A 0
MacBo-
Transcribed Image Text:1 // Step 1: Impórt Jávà člášs Scanner 2 /** * A Java application to input the name and price of * a product, and a discount percentage, then compute * and display the discount price. 4 6. 7 * Step 2: Enter your name for @author and today's date for @version * @author * @version 8 9. 10 11 */ public class DiscountPrice { 12 13 14 public static void main(String [] args) 15 // Step 3: Create a Scanner object to read input from the keyboard 16 17 // 18 19 20 // Step 4: Ask for the product name with prompt 21 // "Enter the product name: " 22 23 24 // Step 5: Read the name of a product from the keyboard 25 // The product name could have multiple words 26 27 28 // Step 6: Trim spaces from both ends of the name 29 30 31 // Step 7: Ask for the product price with prompt 32 // "Enter the price: " 33 34 35 // Step 8: Read a double number as the price of the product 36 37 38 // Step 9: Ask for the discount percentage with prompt 39 // "Enter a discount percentage: 40 41 42 // Step 10: Read a double number as the discount percentage · // For example, 0.1 for 10% and 0. 15 for 15%. 43 44 O Restricted Mode O 0 A 0 MacBo-
23
// Step 5: Read the name of a product from the keyboard
The product name could have multiple words
24
25
//
26
27
28
// Step 6: Trim spaces from both ends of the name
29
30
// Step 7: Ask for the product price with prompt
"Enter the price: "
31
32
//
33
34
35
// Step 8: Read a double number as the price of the product
36
37
// Step 9: Ask for the discount percentage with prompt
"Enter a discount percentage: "
38
39
//
40
41
42
// Step 10: Read a double number as the discount percentage
// For example, 0.1 for 10% and 0.15 for 15%.
43
44
45
46
// Step 11: Display the price of the product with a dollar sign
47
//
and two decimal digits
48
// Sample output:
// The price of iPhone 11 is $749.99.
49
50
51
52
// Step 12: Display the discount price of the product with
53
//
a dollar sign and two decimal digits
54
// The discount price = price * (1 - discount_percentage)
// Sample output:
// The discount price for iPhone 11 is $674.99.
55
56
57
58
}
}
59
60
ricted Mode
O 0 A 0
MacBc
Transcribed Image Text:23 // Step 5: Read the name of a product from the keyboard The product name could have multiple words 24 25 // 26 27 28 // Step 6: Trim spaces from both ends of the name 29 30 // Step 7: Ask for the product price with prompt "Enter the price: " 31 32 // 33 34 35 // Step 8: Read a double number as the price of the product 36 37 // Step 9: Ask for the discount percentage with prompt "Enter a discount percentage: " 38 39 // 40 41 42 // Step 10: Read a double number as the discount percentage // For example, 0.1 for 10% and 0.15 for 15%. 43 44 45 46 // Step 11: Display the price of the product with a dollar sign 47 // and two decimal digits 48 // Sample output: // The price of iPhone 11 is $749.99. 49 50 51 52 // Step 12: Display the discount price of the product with 53 // a dollar sign and two decimal digits 54 // The discount price = price * (1 - discount_percentage) // Sample output: // The discount price for iPhone 11 is $674.99. 55 56 57 58 } } 59 60 ricted Mode O 0 A 0 MacBc
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education