Results 1 to 2 of 2
  1. #1
    kor6666 is offline Member
    Join Date
    Jan 2014
    Posts
    3
    Rep Power
    0

    Default Need some help! new to java!

    Java Code:
    import java.text.DecimalFormat;
    
    import java.util.Scanner;
    
    
    public class Veges {
    
    
    	static Scanner scInput = new Scanner(System.in).useDelimiter("\r\n");
    
    	static Scanner Input = new Scanner(System.in).useDelimiter("\r\n");
    
    	static DecimalFormat fmt2Decimal=new DecimalFormat("0.00"); 
    
     static DecimalFormat fmt4WholeNumber=new DecimalFormat("0000");
    
    
    
    
    
    	public static void main(String[] args) throws Exception 
    
    {
    
    
    
    	int maxOrders, orderNum = 0;
    
    String customerName;
    
    	double adcarrots[] = new double[1000], adonions[] = new double[1000], adpotatos[] = new double[1000], adtomatos[] = new double[1000], adtotalsales[] = new double[1000];
    
    
    
    	int iChoice;
    
    
    
    	do {
    
    dispMainMenu();
    
    iChoice = getUserChoice();
    
    	switch (iChoice) {
    
    	case 1 : orderNum(adcarrots, adonions, adpotatos, adtomatos);
    
    	break;
    
    
    
    	case 2:
    
    
    
    	break;
    
    	case 3:
    
    	break;
    
    	case 4:
    
    	break;
    
    
    
    
    
    
    
    	default: System.out.println("Please enter choices 1 - 4 only.");
    
    }
    
    	}while (iChoice != 4); 
    
    
    
    
    }
    
    
    	private static void orderNum(double adcarrots[],double adonions[],double adpotatos[],double adtomatos[]) {
    
    	int maxOrders, orderNum;
    
    String customerName;
    
    	double carrots, onions, potatos, tomatos;
    
    	do
    
    { 
    
    	System.out.println("How many orders (max 10) : ");
    
    	maxOrders = Input.nextInt();
    
    	}while (maxOrders>10);
    
    	for (orderNum=1; orderNum<=maxOrders; orderNum++)
    
    {
    
    	if((orderNum==maxOrders || (maxOrders<=1)))
    
    {
    
    	System.out.println("----------------------------");
    
    	System.out.println("Please enter vegetable order");
    
    	System.out.println("----------------------------");
    
    	System.out.println("Order <" + orderNum +">");
    
    	System.out.println("Order number: " + "P" + fmt4WholeNumber.format(orderNum));
    
    	System.out.print("Enter customer name: ");
    
    	customerName = Input.next();
    
    	do
    
    {
    
    	System.out.print("Enter number of carrots<@$0.40cts>: ");
    
    	carrots = Input.nextDouble();
    
    	if(carrots >=1000)
    
    {
    
    	System.out.println("Please enter less than 1000");
    
    }
    
    	}while (carrots >=1000);
    
    
    
    	do
    
    {
    
    	System.out.print("Enter number of onions<@$0.45cts>: ");
    
    	onions = Input.nextDouble();
    
    	if(onions >=1000)
    
    {
    
    	System.out.println("Please enter less than 1000");
    
    }
    
    	}while (onions >=1000);
    
    
    
    	do
    
    {
    
    	System.out.print("Enter number of potatos<@$0.35cts>: ");
    
    	potatos = Input.nextDouble();
    
    	if(potatos >=1000)
    
    {
    
    	System.out.println("Please enter less than 1000");
    
    }
    
    	} while (potatos >=1000); 
    
    	do
    
    {
    
    	System.out.print("Enter number of tomatos<@$0.50cts>:");
    
    	tomatos = Input.nextDouble();
    
    	if(tomatos >=1000)
    
    {
    
    	System.out.println("Please enter less than 1000");
    
    }
    
    	} while (tomatos >=1000);
    
    
    
    
    
    }
    
    }
    
    }
    
    
    
    
    
    	private static int getUserChoice() {
    
    	System.out.println("Please select your choice (1-4) :");
    
    	return scInput.nextInt();
    
    }
    
    
     
    
     
    
     
    
    
    
    
    
    
    	static void dispMainMenu() {
    
    	System.out.println("VegeTable Sales");
    
    	System.out.println("---------------");
    
    	System.out.println("1) Enter Order info");
    
    	System.out.println("2) Edit Order info");
    
    	System.out.println("3) Calculate and display orders");
    
    	System.out.println("4) Show vegetable with highest sales, and exit");
    
    }
     }

  2. #2
    kor6666 is offline Member
    Join Date
    Jan 2014
    Posts
    3
    Rep Power
    0

    Default Re: Need some help! new to java!

    for my case 1, how do i display orders 1 to 3 when i type 3 for how many orders , i am getting only order 3 when i typed 3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •