public class Example {
public static void main(String[] args) {
int i=1;
String s1="";
int count=0;
while(i<=12){
switch(i){
case 1: s1="January";
count=31;
break;
case 2: s1="Febuary";
count=28;
break;
case 3: s1="March";
count=31;
break;
case 4: s1="April";
count=30;
break;
case 5: s1="May";
count=31;
break;
case 6: s1="June";
count=30;
break;
case 7: s1="July";
count=31;
break;
case 8: s1="August";
count=30;
break;
case 9: s1="September";
count=31;
break;
case 10: s1="October";
count=31;
break;
case 11: s1="November";
count=30;
break;
case 12: s1="December";
count=31;
break;
}
System.out.print("Month:"+s1 + " "+"Day count=" + count);
System.out.print("\n");
++i;
}
}
}
Create a while loop that will execute the following code 12 times using a counter that...
Using R, Create a while loop which starts x at 1, and prints x: “Are we there yet?” until x reaches 10. (Don’t forget to Increment x by 1 each while loop). To make things interesting, include the line readline(prompt = "Press [enter] to continue") after the print statement stated above. If x is an even number, print x: “Even Number Encountered” And go to the next iteration of the while loop (i.e. No readline – as above)
Create a Book object using a Java program. This object should contain the following variables bookName, bookAuthorName, bookGenre. Now create 3 different book objects and store them in an array. Finally iterate through this array and print out the book names.
This question deals with extending already existing Java code via a while loop. Ask the user how many year inputs he wants to check - an integer. Assume that the user always gives an input which is between 1 and 5 (inclusive). Next, ask the user for K number of year inputs where K = the number user has given as input before (inside a while loop). Check for each year input whether that year is a leap year or...
C++ Write a program that illustrates enumeration types. Define an enumeration type for the months of the year. This should be global. Put it above the main program. Declare a variable of the enumerated type called month; Declare an array of unsigned integers called year[12] and initialize the array to the days in each month. (Just assume 28 for February.) 1. Write a loop that will progress from January through December printing out the days in each month. The index...
JAVA I. Using the Event Class created previously, create an array of objects; II. Demonstrate passing array reference to a method; III. Demonstrate creating array of objects that prints out only x 0.0 for all objects. PROJECT 5C - ARRAYS Create a new file called " EventArray5C". There are some "challenging" directions in this project. . 1.Prepare a document box (tell me that task(s) the application is to accomplish, how it will accomplish the tasks, the author of...
Create a program named Lab14B. You will create a nested loop in this program by putting Lab14A’s for loop inside a while loop. In the new while loop, you will read integers from the file, Lab14B.txt, and determine if the number is prime (using the copied loop from Lab14A). Stop the while loop when you reach the end of file. Copy your code from Lab14A into your new program Add a while not eof loop around that code, and also...
Please design, write the code and create the requisite submission files in C++ for the following problem: A menu-driven program that offers the user 5 options as follows: Menu: 1. Display array 2. Add up all elements in the array and display that number. 3. Add 1 to each element in the array. 4. Swap the values in row one with the values in row three. 5. Exit In main(), declare and initialize a 2-dimensional array that contains 5 x...
Please help me do these two programs in JAVA Program 1 Create a program that will create an ArrayList of Strings. Then input names until “quit” and use the enhanced for loop to print out the names. Program 2 Using enum and array of objects Use the enumerated type of: enum CarType { PORCHE, FERRARI, JAGUAR, UNKNOWN } And place it in its own file. Then make a Car class that has the following: Make of CarType Year,...
create case 4 do Method 1:copy item by item and skip the item you want to delete after you are done, delete the old file and rename the new one to the old name. #include int main(void) { int counter; int choice; FILE *fp; char item[100]; while(1) { printf("Welcome to my shopping list\n\n"); printf("Main Menu:\n"); printf("1. Add to list\n"); printf("2. Print List\n"); printf("3. Delete List\n"); printf("4. Remove an item from the List\n"); printf("5. Exit\n\n"); scanf("%i", &choice); switch(choice) { case 1:...
Lab 3 Step One First, create an empty directory for lab3. There is no starter code for this lab. You will be throwing and catching exceptions in this exercise. Create a file called RuntimeException.h and put the following code in it. #include <string> class RuntimeException { private: string errorMsg; public: RuntimeException(const string& err) { errorMsg = err; } string getMessage() const { return errorMsg; } } Step Two In a new .cpp file in your directory, write a main function...