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...
This is a basic java program where you convert units using only loops, control statements and format modifiers: Create a Java program named UnitConversion.java that converts the following: 1. Liter to gallon 2. Gallon to liter 3. Kilometers to miles 4. Miles to kilometers The conversion formulas: 1 liter = 0.264172 gallon 1 gallon = 3.78541 liters 1 kilometer = 0.621 miles I mile = 1.609 kilometers
Create a program in Java with the following requirements: Using a Scanner and print statements, ask the user to input 3 numbers. Use Java’s int data type…don’t worry about error checking for this assignment (assume the user doesn’t try to break your program) Store these three numbers into three variables Calculate the sum of all three numbers Calculate the product of all three numbers If all three numbers are even, output “Lucky Duck!” If all three numbers are odd, output...
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...
Using the Phyton program; Write a program using loop (use days of the week as a list) to ask the user to enter the total hours spend studying for each day of the week. How many hours spent studying on Monday? How many hours spent studying on Tuesday? Count and display the number of days the user 1) studied less than 4 hours. 2) studied between 4- 8 hours 3) studied more than 8 hours
Write a java program that uses a loop to input, from the user not using gui, a collection of values that are the number of steps taken each day for a sequence of days and stores those amounts in an array. the array length should be 31, The user is not required to enter 31 values. the program determines and displays the largest number of steps for a single day, the smallest number of steps for a single day and...