Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > The IT Pro > Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Programming A discussion forum for programs and programming used in tech-related businesses.

Reply
 
LinkBack Thread Tools
Old 07-25-2007, 04:01 AM   #1 (permalink)
Registered User
 
Join Date: Feb 2007
Location: Shibuya,Japan
Posts: 291
OS: Windows XP Professional SP2, Windows Vista Business Edition

My System

Java Help!!

Hi everyone, I having a minor difficulty in sorting the menu.

Quote:
Create a class for service offered by the hair styling salon. Data fields include a String to hold the service description (for example, “Cut”, “Shampoo”, or “Manicure”), a double to hold the price and an integer to hold the average minutes it takes to perform the service. The class should include the following:-
  1. Constructor
  2. Mutator
  3. Accesor
  4. toString method

Write a program that contains an array to hold six services as below:-



Your program should include a menu that view the report based on service, price or time depend on the user’s input. Sort your report in ascending order.

Example:

Here is my coding .... please help me... thanks..

Code:
import java.io.*;

class TestService{
	public static void main(String args []){
		
		int selection;
	
		
		Service array[]=new Service[6];
		
		
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		System.out.println("View The Report By \n");
		System.out.println("1. Service");
		System.out.println("2. Price");
		System.out.println("3. Time");
		System.out.println("4. Exit");
		
		try{
		
		do{
			
		
		System.out.print("Enter selection :");
		selection =Integer.parseInt(br.readLine());
		
		
		if(selection ==1){
		
				
			array[0]=new Service("Cut",8.00,15);
			array[1]=new Service("Shampoo",4.00,10);
			array[2]=new Service("Manicure",18.00,30);
			array[3]=new Service("Style",48.00,55);
			array[4]=new Service("Permanent",18.00,35);
			array[5]=new Service("Trim",6.00,5);
			
		}else if(selection ==2){
			array[0]=new Service("Shampoo",4.00,10);
			array[1]=new Service("Trim",6.00,5);
			array[2]=new Service("Cut",8.00,15);
			array[3]=new Service("Manicure",18.00,30);
			array[4]=new Service("Permanent",18.00,35);
			array[5]=new Service("Style",48.00,55);
		
			
		}else if(selection ==3){
			array[0]=new Service("Trim",6.00,5);
			array[1]=new Service("Shampoo",4.00,10);
			array[2]=new Service("Cut",8.00,15);
			array[3]=new Service("Manicure",18.00,30);
			array[4]=new Service("Permanent",18.00,35);
			array[5]=new Service("Style",48.00,55);}
		
		}while(!=4);
		
		System.out.println();
		System.out.println("Service"+"\t\t"+"Price<$>" +"\t" + "Time<Minutes>");
		System.out.println("=======" + "\t\t" +"========" +"\t" + "=============");

		
		for(int a=0;a<6;a++)
		System.out.println(array[a].toString());
		}
		

		catch(NumberFormatException ex){		
		System.out.println("You can only enter number");
		}
		catch(IOException ex){
			System.out.println("Input error");
		}
	}
}
WingKalimdor is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 08-07-2007, 01:07 AM   #2 (permalink)
Registered User
 
Join Date: Jul 2007
Location: Aberdeen
Posts: 32
OS: Windows Vista Premium


Confused Re: Java Help!!

Is your problem getting the menu to come up or getting the final result sorted?

Excuse my ignorance but i'm more used to building a GUI with drop down menus etc
little_cruden is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 08-10-2007, 04:53 PM   #3 (permalink)
Registered User
 
Join Date: Aug 2005
Location: Ohio
Posts: 207
OS: VISTA


Re: Java Help!!

This is a question straight from a school book, we are not here to do your homework we are here to help people who are acualy trying to learn to code
Damion is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 08-13-2007, 09:00 AM   #4 (permalink)
Registered User
 
ricer333's Avatar
 
Join Date: Sep 2004
Posts: 302
OS: Vista (on Laptop) WinXP Pro SP3 (on Desktop)


Re: Java Help!!

I agree. Most of us that have been around here for awhile see this from time to time. Students just wanting the answers. Most of us have been in the students shoes and could easily provide the answer, however, this would ultimately create some stupid programmers.

I will say this, if you have a specific question (i.e. 'why is my program not getting an expected result') we can help. However, do not attempt to just toss code up (or in the extremem case = no code up) and ask us to write the programs for you.

There is a reason for everything. There is a reason why you are taking a programming course. There is a reason for the classwork. I can safely say I struggled quite a lot at my first C++ course, but the struggles are what make you stronger!

Okay, off of my soap box.
__________________
AMD X2 5000+ Black w/ XFX GeForce 8200 MoBo
4GB OCZ DDR2 RAM
3/4 of a TB of data storage between 2 HDD's (no RAID)
ricer333 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 01:25 AM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85