Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Using any means at your disposal (MS Word, MS Paint, Adobe Photoshop, or hand drawn, etc.), draw a flowchart that should accept a number.

image text in transcribed

image text in transcribed

1. Using any means at your disposal (MS Word, MS Paint, Adobe Photoshop, or hand drawn, etc.), draw a flowchart that should accept a number. This number will be used by the user to enter the number of integers. From the integers entered, print the highest number. Your output should be hand drawn or a JPEG (.jpg) file with "LASTNAME_CLASSCODE_MIDTERMI as its filename. (10 pts) 2. Write a program that prompts the user to input an integer (not a String) and then outputs both the individual digits of the number and the sum of the digits. For example, the program should: output the individual digits of 3456 as 3 4 5 6 and the sum as 18, output the individual digits of 2345526 as 2 3 4 5 5 2 6 and the sum as 27, and output the individual digits of -2345 as 2 3 4 5 and the sum as 14. Use the class name "LASTNAME_CLASSCODE_MIDTERM2 when writing your program. (15 pts) 3. Consider the following scenario: A high school has 1000 students and 1000 lockers, one locker for each student. On the first day of school, the principal plays the following game: She asks the first student to open all the lockers. She then asks the second student to close all the even-numbered lockers. The third student is asked to check every third locker. If it is open, the student closes it; if it is closed, the student opens it. The fourth student is asked to check every fourth locker. If it is open, the student closes it; if it is closed, the student opens it. The remaining students continue this game. In general, the nth student checks every nth locker. If it is open, the student closes it; if it is closed, the student opens it. After all the students have taken turns, some of the lockers are open and some are closed. The program below, when ran, will prompt the user to enter the number of lockers in the school. After the game is over, the program will output the number of lockers and the lockers numbers of the lockers that are open. However, the statements are in the wrong order, and there are some bugs in this program. Rearrange the statements and also find and remove the bugs so that the program can run properly. RENAME THE CLASS TO "LASTNAME_CLASSCODE_MIDTERM3. Underline/Highlight the changes you have made. (10 pts). Include also a screenshot of the program's code and output. * The program below, while has the correct output, doesn't follow the game's logic at all. * Instead, it follows a certain pattern that's present in the game. * Consider the 100th locker. Following the games rules, this locker should be visited by the 1st, 2nd, * 3rd, 4th, 5th, 10th, 20th, 25th, 50th, and 100th student. Coincidentally, these are also the positive * divisors of 100. Similarly, the 30th locker is visited by the students whose numbers are 1, 2, 3, 5, 6 * 10, 15, and 30. Note that if the numbers of positive divisors of a locker number is odd, then at the * end of the game, the locker is open. if the numbers of positive divisors of a locker number is even, * then at the end of the game, the locker is closed. */ import java.util.Scanner; public class MidtermExam3{ public static void main(String[] args) { Scanner keyboard - new Scanner(System.in); int studentVisitCount - @; System.out.print("Enter the number of lockers: "); int numberOfLockers - console.nextInt(); for(int x=0; x } System.out.println("The number of lockers and students are: "+numberOfLockers); System.out.print("The locker numbers of lockers that are left open at the end of the game are: "); )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions

Question

1. What is meant by Latitudes? 2. What is cartography ?

Answered: 1 week ago