How to start a java program for 12 days of Christmas lyrics using if statements.
public class main{
public static void main(String[] args) {
int days;
System.out.print("Enter number: ");
days =12;
System.Out.Println()
//using for loop
for(int i=1; i<=number; i--) {
System.out.print("On the ");
if(i==1){
System.out.print("first");
//breaking the loop
break;
}
if(i==2){
System.out.print("second");
//breaking the loop
break;
}
if(i==3){
System.out.print("third");
//breaking the loop
break;
}
if(i==4){
System.out.print("fourth");
//breaking the loop
break;
}
if(i==5){
System.out.print("fifth");
//breaking the loop
break;
}
if(i==6){
System.out.print("sixth");
//breaking the loop
break;
}
if(i==7){
System.out.print("seventh");
//breaking the loop
break;
}
if(i==8){
System.out.print("eighth");
//breaking the loop
break;
}
if(i==9){
System.out.print("ninth");
//breaking the loop
break;
}
if(i==10){
System.out.print("tenth");
//breaking the loop
break;
}
if(i==11){
System.out.print("eleventh");
//breaking the loop
break;
}
if(i==12){
System.out.print("twelth");
//breaking the loop
break;
}
System.out.println(" day of Christmas my true love gave to me");
if(i==12)
System.out.print("twelve drummers drumming, ");
if(i==11)
System.out.println("eleven pipers piping, ");
if(i==10)
System.out.print("ten lords a-leping, ");
if(i==9)
System.out.print("nine ladies dancing, ");
if(i==8)
System.out.println("eight maids a-milking, ");
if(i==7)
System.out.print("seven swans a-swimming, ");
if(i==6)
System.out.print("six geese a-laying, ");
if(i==5)
System.out.println("five gold rings,");
if(i==4)
System.out.print("four calling birds, ");
if(i==3)
System.out.print("three french hens, ");
if(i==2)
System.out.print("two turtle doves\nand ");
if(i==1)
System.out.println("a partridge in a pear tree.");
}// end for
} // end main
} // end class
How to start a java program for 12 days of Christmas lyrics using if statements.
Java hw Write a program that outputs the lyrics for “Ninety-nine Bottles of Beer on the Wall.” Your program should print the number of bottles in English, not as a number. For example: Ninety-nine bottles of beer on the wall, Ninety-nine bottles of beer, Take one down, pass it around, Ninety-eight bottles of beer on the wall. ... One bottle of beer on the wall, One bottle of beer, Take one down, pass it around, Zero bottles of beer on...
Develop a MATLAB program that determines the number of days until Christmas (December 25th) given any 3. date. The program asks the user to enter the date (month and date). The program works for just one year (i.e., days until Christmas during a given year, as opposed to future years). Execute the program for the following dates c. July 4 d. December 26th (Chow should the program respond?) a. December 24th b. April 30 Develop a MATLAB program that determines...
Write a program that uses repetition and switch statements to print the song "The Twelve Days of Christmas." One switch statement should be used to print the day (i.e., "first," "second," etc.).A separate switch statement should be used to print the remainder of each verse.
3. Using no date-specific Java libraries, write a program that computes the number of days between any two dates (inclusive). You must take into account leap years. The rule for computing a leap year is as follows: If the year is divisible by 4 it is a Leap Year ... Unless the year is divisible by 100, then it is _not_ a Leap Year ... Unless the year is divisible by 400, then it _is_ a Leap Year. During a...
How would you write the following program using switch statements instead of if-else statements (in java) import java.util.*; public class ATM { public static void main(String[] args) { Scanner input = new Scanner (System.in); double deposit, withdrawal; double balance = 6985.00; //The initial balance int transaction; System.out.println ("Welcome! Enter the number of your transaction."); System.out.println ("Withdraw cash: 1"); System.out.println ("Make a Deposit: 2"); System.out.println ("Check your balance: 3"); System.out.println ("Exit: 4"); System.out.println ("***************"); System.out.print ("Enter Your Transaction Number "); transaction...
Problem 1 Write a program that outputs the lyrics for “Ninety-nine Bottles of Beer on the Wall.” Your program should print the number of bottles in English, not as a number. For example: Ninety-nine bottles of beer on the wall, Ninety-nine bottles of beer, Take one down, pass it around, Ninety-eight bottles of beer on the wall. ... One bottle of beer on the wall, One bottle of beer, Take one down, pass it around, Zero bottles of beer on...
Java Eclipse program Write statements to declare and initialize eight constants, one for each of the primitive types in Java. boolean, byte, char, short, int, long, float and double. Add statements to print the name of the constant and its value to your VariableDefinitions.javaprogram and compile the program. Assign a new value to one of the constants and compile. Comment out the lines of code that cause compilation errors but do not delete them and recompile your program.
I need a java program that print the first and last numbers from 12 to 19 using Keyboard
How do I create a simple java program file that opens and reads a file using java.io? I have the file Im supposed to open and read but I dont know how to code it to open and read the file?
Must use JOPTIONPANE. Using arrays and methods create a JAVA program. Create a java program that holds an array for the integer values 1-10. Pass the array to a method that will calculate the values to the power of 2 of each element in the array. Then return the list of calculated values back to the main method and print the values