Java Program - Calculating Retail Price - Sample Program Calculates the retail price of an item with validating data and not allowing negative numbers

Java Program - Calculating Retail Price - Sample Program...

This preview shows page 1 - 2 out of 2 pages.

Sample Program: Calculates the retail price of an item with validating data and not allowing negative numbers. // Program 7-2 import java.util.Scanner; public class Program7_2 { public static void main(String[] args) { // Create a Scanner object for keyboard input. Scanner keyboard = new Scanner(System.in); // Local variable String doAnother; do { // Calculate and display a retail price. showRetail(); // Do this again? System.out.print("Do you have another item? (Enter y for yes): "); doAnother = keyboard.next(); } while (doAnother.equals("y") || doAnother.equals("Y")); } // The showRetail module gets an item's wholesale cost // from the user and displays its retail price. public static void showRetail() { // Create a Scanner object for keyboard input.
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture