Click here to Skip to main content
15,923,789 members
Home / Discussions / Java
   

Java

 
GeneralRe: Parsing Text Files and Spliting on '>' Pin
meixiang69-Oct-09 8:56
meixiang69-Oct-09 8:56 
GeneralRe: Parsing Text Files and Spliting on '>' Pin
42774809-Oct-09 9:42
42774809-Oct-09 9:42 
GeneralRe: Parsing Text Files and Spliting on '>' Pin
meixiang69-Oct-09 9:56
meixiang69-Oct-09 9:56 
Question12 days of christmas Pin
Shah Ravi8-Oct-09 9:05
Shah Ravi8-Oct-09 9:05 
AnswerRe: 12 days of christmas Pin
Wes Aday8-Oct-09 9:51
professionalWes Aday8-Oct-09 9:51 
GeneralRe: 12 days of christmas Pin
Shah Ravi8-Oct-09 10:19
Shah Ravi8-Oct-09 10:19 
GeneralRe: 12 days of christmas Pin
David Skelly8-Oct-09 22:13
David Skelly8-Oct-09 22:13 
AnswerRe: 12 days of christmas Pin
42774809-Oct-09 3:16
42774809-Oct-09 3:16 
This is what I understood from the question:

import javax.swing.*;

public class TwelveDays 
{
	public static void main(String[] args) 
	{
		for (int i = 0; i < 12; i++)
		{
			int day = Integer.parseInt(JOptionPane.showInputDialog("What Day ?"));
			switch(day)
			{
			case 1:
				showIT(day);
				break;
			case 2:
				showIT(day);
				break;
			case 3:
				showIT(day);
				break;
			case 4:
				showIT(day);
				break;
			case 5:
				showIT(day);
				break;
			case 6:
				showIT(day);
				break;
			case 7:
				showIT(day);
				break;
			case 8:
				showIT(day);
				break;
			case 9:
				showIT(day);
				break;
			case 10:
				showIT(day);
				break;
			case 11:
				showIT(day);
				break;
			case 12:
				showIT(day);
				break;
			default:
				JOptionPane.showMessageDialog(null,"Can't you count", "Ha Ha Ha",JOptionPane.WARNING_MESSAGE);
				break;
			}
		}
	}
	
	public static String RemainingSong(int day)
	{
		String song = "";
		String complete [] = {"Verse 1 \n","Verse 2 \n","Verse 3 \n","Verse 4 \n","Verse 5 \n","Verse 6 \n","Verse 7 \n","Verse 8 \n","Verse 9 \n","Verse 10 \n","Verse 11 \n","Verse 12 \n"};
		switch (day)
		{
		case 1:
			song = looper(complete,0);
			break;
		case 2:
			song = looper(complete,1);
			break;
		case 3:
			song = looper(complete,2);
			break;
		case 4:
			song = looper(complete,3);
			break;
		case 5:
			song = looper(complete,4);
			break;
		case 6:
			song = looper(complete,5);
			break;
		case 7:
			song = looper(complete,6);
			break;
		case 8:
			song = looper(complete,7);
			break;
		case 9:
			song = looper(complete,8);
			break;
		case 10:
			song = looper(complete,9);
			break;
		case 11:
			song = looper(complete,10);
			break;
		case 12:
			song = looper(complete,11);
			break;
		default:
			JOptionPane.showMessageDialog(null,"Can't you count", "Ha Ha Ha",JOptionPane.WARNING_MESSAGE);
			break;
		}
	return song;
	}
	
	public static String looper(String[] a,int number)
	{
		String temp = "";
		for (int i = number; i < a.length; i++)
		{
			temp = temp + a[i];
		}
		return temp;
	}
	public static void showIT(int day)
	{
		JTextArea songArea = new JTextArea(20, 30);
		JScrollPane scroller = new JScrollPane(songArea);
		songArea.setText(RemainingSong(day));
		JOptionPane.showMessageDialog(null, scroller, "Twelve Days of Christmas", 
		JOptionPane.PLAIN_MESSAGE); 
	}
}


Fill in the song lines in place of the verses.

Good Luck
QuestionJ2METext Field Problem Pin
DarkSorrow388-Oct-09 4:56
DarkSorrow388-Oct-09 4:56 
AnswerRe: J2METext Field Problem Pin
42774809-Oct-09 3:20
42774809-Oct-09 3:20 
QuestionEpub-LRFTools [modified] Pin
sharkbc7-Oct-09 21:54
sharkbc7-Oct-09 21:54 
AnswerRe: Epub-LRFTools Pin
Nagy Vilmos7-Oct-09 22:04
professionalNagy Vilmos7-Oct-09 22:04 
GeneralRe: Epub-LRFTools Pin
sharkbc7-Oct-09 23:30
sharkbc7-Oct-09 23:30 
AnswerRe: Epub-LRFTools Pin
42774808-Oct-09 1:04
42774808-Oct-09 1:04 
GeneralRe: Epub-LRFTools Pin
sharkbc8-Oct-09 17:11
sharkbc8-Oct-09 17:11 
GeneralRe: Epub-LRFTools Pin
42774809-Oct-09 3:21
42774809-Oct-09 3:21 
Question[Message Deleted] Pin
AsianMike7-Oct-09 3:53
AsianMike7-Oct-09 3:53 
AnswerRe: Need Memory Leak Help Pin
David Skelly7-Oct-09 4:14
David Skelly7-Oct-09 4:14 
QuestionNeed help with initialize (!M) Pin
wkid876-Oct-09 7:00
wkid876-Oct-09 7:00 
AnswerRe: Need help with initialize (!M) Pin
wkid876-Oct-09 7:06
wkid876-Oct-09 7:06 
GeneralRe: Need help with initialize (!M) Pin
EliottA6-Oct-09 7:23
EliottA6-Oct-09 7:23 
AnswerRe: Need help with initialize (!M) Pin
Richard MacCutchan6-Oct-09 10:54
mveRichard MacCutchan6-Oct-09 10:54 
QuestionNeed Help Pin
ajaysud955-Oct-09 2:09
ajaysud955-Oct-09 2:09 
AnswerRe: Need Help Pin
Richard MacCutchan5-Oct-09 6:50
mveRichard MacCutchan5-Oct-09 6:50 
AnswerRe: Need Help Pin
zero.zero5-Oct-09 20:06
zero.zero5-Oct-09 20:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.