Results 1 to 7 of 7

Thread: Working On Code

  1. #1
    maximumammo is offline Banned
    Join Date
    Apr 2012
    Posts
    13
    Rep Power
    0

    Default Working On Code

    Hello everyone, I am new to Java and attempting to write a program using an array. The program should ask for the name, number, and amount spent for 10 customers, it should then determine which customer spent the most and display that customers info.

    This is what I have so far but I dont know how to have it find the max and then display ALL that customers info, any help is welcome.

    O I am also trying to have the customer enter their phone number in the following format, xxx-xxx-xxxx (example: 100-897-9078) and then determine if the phone number has 10 digits. thanks again


    ----------------------------------------------------------------------------------------------------

    Java Code:
    import java.util.Scanner;
    
    
    public class Assignment4 {
    	public static void main (String[] args)
    	
    	{	
    		//--------------------------------------------------------------
    		// This program is designed to award the highest spending
    		// customer of the day with a $100 dollar gift card, prompting
    		// the customer to enter their name, phone number, and amount 
    		// spent on that day.
    		//--------------------------------------------------------------
    		
    	Scanner scan = new Scanner (System.in);
    	double max = 0.0;
    	double amount;
    	double[] customers = new double[10];
    	System.out.println(" The number of customers are: " + customers.length);
    	
    	System.out.println("Amount Spent: ");
    	amount = scan.nextDouble();
    	
    for (int index = 0; index < customers.length; index++)
    	
    { System.out.println("Enter Your Name:");
    String Name = scan.nextString();
    
    System.out.println("Enter Your Phone Number:");
    Double Number = scan.nextDouble();
    
    System.out.println("Enter Amount Spent:");
    Double Amount = scan.nextDouble();
    
    System.out.println("Thank You,");
    }
    	
    		
    		
    	
    	}
    }
    Thanks!!!!!!
    Last edited by DarrylBurke; 04-04-2012 at 11:04 AM. Reason: added [code] ... [/code] tags; corrected mangled topis line

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: Working On Code

    Look around the forum FAQs and discover how to post code so that it retains its formatting.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,663
    Blog Entries
    7
    Rep Power
    21

    Default Re: Working On Code

    Quote Originally Posted by DarrylBurke View Post
    Look around the forum FAQs and discover how to post code so that it retains its formatting.
    I fixed those code tags.

    kind regards,

    Jos (janitor ;-)
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    ojn
    ojn is offline Senior Member
    Join Date
    Sep 2008
    Location
    Stockholm, Sweden
    Posts
    119
    Rep Power
    0

    Default Re: Working On Code

    Ok.. so did you have an actual question?

  5. #5
    maximumammo is offline Banned
    Join Date
    Apr 2012
    Posts
    13
    Rep Power
    0

    Default Re: Working On Code

    Quote Originally Posted by ojn View Post
    Ok.. so did you have an actual question?
    Yes, how do I have the program find the maximum amount spent and display that amount with the corresponding customer info.

    for example,

    ------------------------------------------------------------
    Joe Smith, 111-111-1111, $89.55
    Joe Smith Jr, 222-222-2222, $55.40
    Joe Smith Sr, 333-333-3333, $75.10
    Mrs. Joe Smith, 444-444-4444, $210.00

    The Winner is Ms. Joe Smith, 444-444-4444, $210.00

    ------------------------------------------------------------

  6. #6
    maximumammo is offline Banned
    Join Date
    Apr 2012
    Posts
    13
    Rep Power
    0

    Default Re: Working On Code

    Quote Originally Posted by JosAH View Post
    I fixed those code tags.

    kind regards,

    Jos (janitor ;-)
    Thanks!

  7. #7
    shamssss.169 is offline Member
    Join Date
    Apr 2012
    Location
    Texas USA
    Posts
    2
    Rep Power
    0

    Default Re: Working On Code

    Spoonfeeding deleted.

    Jos
    Last edited by JosAH; 04-04-2012 at 05:20 PM.

Similar Threads

  1. Replies: 1
    Last Post: 03-25-2012, 04:40 AM
  2. Replies: 2
    Last Post: 01-04-2011, 05:30 AM
  3. Been working on a code for days
    By Link01 in forum Java Applets
    Replies: 5
    Last Post: 05-19-2010, 04:55 PM
  4. Why is the code not working
    By sanox in forum New To Java
    Replies: 12
    Last Post: 09-08-2009, 12:28 PM
  5. JNI: Why this code not working?
    By playwin2 in forum Advanced Java
    Replies: 5
    Last Post: 11-25-2008, 02:12 PM

Posting Permissions

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