Question

In: Computer Science

Write a program that uses a for loop to print One of the months of the...

Write a program that uses a for loop to print

One of the months of the year is January

One of the months of the year is February

...

Solutions

Expert Solution

//class definition
public class months {

//main function definition
public static void main(String[] args) {

      //define string array and initialize it with names of 12 months
      String[] months ={"January","February","March","April","May","June","July","August","September","October","November","December" };
     
      //for loop to print desired result
      //each iteration will print a line for a month
      for (int i=0;i<12;i++){
        System.out.println("One of the months of the year is "+ months[i]);
      }
}

}


Related Solutions

Write a Java program using jGRASP directions are as follows: Uses a while loop to print...
Write a Java program using jGRASP directions are as follows: Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop to print the numbers from 42 - 56. Uses a for loop to print the numbers from 87 - 95. Asks the user for 2 numbers. Uses a loop to print all numbers between the given numbers, inclusive. Note: Consider that your user's second number can be lower! (see example below) Note: Also consider...
Using the software Emulator EMU8086, write an assembly program that uses a loop to print "HELLO...
Using the software Emulator EMU8086, write an assembly program that uses a loop to print "HELLO WORLD" 3 times and "LIFE" 2 times. Example: HELLO WORLD HELLO WORLD HELLO WORLD LIFE LIFE   
2) create a python program that uses a for loop and range to print out the...
2) create a python program that uses a for loop and range to print out the values 10 8 6 4 2 3) Create a python program that yses a for loop to print out ["bob","al","bert"]
Write a program using c++. Write a program that uses a loop to keep asking the...
Write a program using c++. Write a program that uses a loop to keep asking the user for a sentence, and for each sentence tells the user if it is a palindrome or not. The program should keep looping until the user types in END. After that, the program should display a count of how many sentences were typed in and how many palindromes were found. It should then quit. Your program must have (and use) at least four VALUE...
Write a program that uses loops (both the for-loop and the while loop). This assignment also...
Write a program that uses loops (both the for-loop and the while loop). This assignment also uses a simple array as a collection data structure (give you some exposure to the concept of data structure and the knowledge of array in Java). In this assignment, you are asked to construct an application that will store and retrieve data. The sequence of data retrieval relative to the input is Last In First Out (LIFO). Obviously, the best data structure that can...
Write a program that uses nested for loops to print a multiplication table. Your program should...
Write a program that uses nested for loops to print a multiplication table. Your program should print out the multiplication table starting a 1 and going to 12. Output should be like: 1 x 1 = .1 x 2 = 2
Write a program that uses a while loop with a priming read to ask the user...
Write a program that uses a while loop with a priming read to ask the user to input a set positive integers. As long as the user enters a number greater than -1, the program should accumulate the total, keep track of the number of numbers being entered and then calculate the average of the set of numbers after the user enters a -1. This is a sentinel controlled-loop. Here is what a sample run should look like: Enter the...
Write a program that uses a for loop output a string in reverse printing it character...
Write a program that uses a for loop output a string in reverse printing it character by character. C++ Program Example: "Enter some text:" this is a test "your text in reverse is:" tset a si siht Please note that you can find the length of the string by using the length function: string str = "hello" cout << str.length(); Also you can et a character in a string by providing an index to the function string str = "hello"...
Write a PYTHON program that uses a while loop to prompt for 5 integers. If the...
Write a PYTHON program that uses a while loop to prompt for 5 integers. If the number is equal to 99, display "Ninety-nine", otherwise display "no-match". If the number is equal to 75, display "Seventy-five", otherwise display "no-match".
Using Matlab Write a program that print the following matrix. (hint: use nested for-loop and if-statement)...
Using Matlab Write a program that print the following matrix. (hint: use nested for-loop and if-statement) mat = [2 -1 0 0 0 -1 2 -1 0 0 0 0 -1 2 -1 0 0 0 -1 2];
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT