I am not asking for someone to do my project for me, I am simply asking for some guidance or a nudge in the right direction. I will put in the time and effort into getting this program to run!!
import java.util.Scanner; // Needed for the Scanner class.
import java.io.*; // Needed for the File I/O classes
public class Samsstore2
{
public static void main(String[] args) throws IOException
{
int menuOption = 0; // Number on the option menu.
int input; // Hold user input.
boolean menu;
// Create a Scanner object for keyboard input
Scanner keyboard = new Scanner( System.in );
// Get the menu option from the user.
System.out.print("Choose one of the following \n" +
"by typing 1, 2, 3, or 4:");
System.out.println("\n");
System.out.println("1. Enter Customer Information");
System.out.println("2. Price Lookup");
System.out.println("3. Display total bill ");
System.out.println("4. quit");
System.out.println();
menuOption = keyboard.nextInt();
if (menuOption == 1)
{
//Variables
String name; //Hold customers name
String address; //Hold customers address
String email; //Hold customers email
String product; //Hold type of product customer is wanting to purchase
int quantity; //Hold quantity of product that the customer is wanting to purchase
double price; //Hold price of product that the customer is wanting to purchase
char repeat; //Hold the @ symbol
String info; //Hold input
String customerFile;
String fileName;
//Open the file
PrintWriter outputFile = new PrintWriter("C:customerFile.txt");
//Get the customers name
System.out.print( "\n" + "Enter Customer name: " );
name = keyboard.nextLine();
//Write the name to the file.
outputFile.println(name);
//Consume the remaining newline.
keyboard.nextLine();
//Get the customers address
System.out.print( "Enter Customer address: " );
address = keyboard.nextLine();
//Write the name to the file.
outputFile.println(address);
//Get the customers email
System.out.print( "Enter Customer email: " );
email = keyboard.nextLine();
//Write the name to the file.
outputFile.println(email);
//Get data and write it to a file.
outputFile.close();
System.out.println( "\n" +
"This customer has been added \n" +
"to the customer list under (C:customerFile.txt).");
}
else if (menuOption == 2)
{
int productPrice; //To hold the users choice
System.out.print("\n" + "Choose from one of the following products to look up the price: ");
//Consume the remaining newline.
keyboard.nextLine();
System.out.println("\n");
//List the products
System.out.println("1. Shoes");
System.out.println("2. T-Shirts");
System.out.println("3. Shorts");
System.out.println("4. Caps");
System.out.println("5. Jackets");
System.out.println();
productPrice = keyboard.nextInt();
switch (productPrice)
{
case 1:
System.out.print("$30");
break;
case 2:
System.out.print("$10");
break;
case 3:
System.out.print("$30");
break;
case 4:
System.out.print("$20");
break;
case 5:
System.out.print("$50");
break;
default:
System.out.println("You did not choose a valid product");
}
// End
System.exit(0);
}
else if (menuOption == 3)
{
System.out.print("\n" + "Enter customer's name:");
String name = keyboard.nextLine();
//Consume the remaining newline.
keyboard.nextLine();
System.out.print("Enter product: ");
String product = keyboard.nextLine();
System.out.print("Enter quantity of product: ");
int quantity = keyboard.nextInt();
System.out.print("Enter price of product: ");
double price = keyboard.nextDouble();
double totalBill = quantity * price;
double totalTax = totalBill * 0.08;
double totalCost = totalBill + totalTax;
double taxRate = 0.08;
System.out.println( "\n" +
" \n" +
name + "\n" +
"Product Purchased" + " " +
"Quantity" + " " +
"Total Cost" +
"\n" +
product + " " +
quantity + " " +
" $" + String.format("%.2f", totalBill) +
" \n" +
"Tax (@" + taxRate + "%):" + " $" + String.format("%.2f", totalTax) + "\n" +
"Total Cost: " + " $" + String.format("%.2f", totalCost) + " \n" +
"");
}
else if (menuOption == 4)
{
System.out.println("4. Quit");
}
}
}
Mod edit - Please

New Topic/Question
Reply



MultiQuote







|