Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a java program that prompts the user to enter the weight of an item in ounces and the price per pound. Then ask

image text in transcribed 

Write a java program that prompts the user to enter the weight of an item in ounces and the price per pound. Then ask user to enter his/her name (User can enter a string with any order of lower/upper case characters).The name will include their first and last name with a space between them. Note that the name will be saved in one string variable. Do not use two different variables for first name and last name. Your program should calculate the item's weight in pounds then calculate the cost of buying an item.. 1 Pound 16 Once Then generate a two-digit random number as a confirmation code. Your program should convert the user's name to all uppercase characters and replace the space between first and last names with a period (.). Your code should print a receipt that includes the cashier's name (all uppercase with a period for separating the first and last name) and the confirmation code. The output should also include the unit price, weight in pounds and the total price. You should use NumberFormat to print any currency and DecimalFormat with 2 decimal places for printing the weight. Note: Test your code for a variety of inputs. Remember, the code with the errors will not be graded. Make sure you use concepts and statements that we covered in chapters 1, 2, and 3. The projects that uses the concepts that we have not covered yet will receive zero. Sample Output: Enter your name: Nazli Mehrazar Enter the item's weight in ounces: 41 Enter the price per pound: 5.25 11 Welcome NAZLI.MEHRAZAR /// ***** Unit Price: Weight: ===== ==== Total: 5.25 per pound 2.56 pounds 13.44 Confirmation Code: 32

Step by Step Solution

There are 3 Steps involved in it

Step: 1

java import javautilScanner import javatextNumberFormat public class WeightPriceCalculator public st... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Java Programming, Comprehensive Version

Authors: Y. Daniel Liang

10th Edition

133761312, 978-0133761313

More Books

Students also viewed these Programming questions

Question

What is linear programming?

Answered: 1 week ago

Question

What are the 5 Cs of marketing channel structure?

Answered: 1 week ago