Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Written Java 1. Initialize an int variable named as sum to 0. Write the while loop that lets the user enter a number The number

Written Java

image text in transcribed

1. Initialize an int variable named as sum to 0. Write the while loop that lets the user enter a number The number should be added to sum and the result is stored back to the variable sum. The loop should iterate as long as sum contains a value less than 200. After the loop stop, display message "sum the loop stops" 2. Write a do-while loop that asks the user to select a task from the following menu to continue 1. Task 1 2. Task 2 3. Task3 0. Exit Read the task selected from the keyboard then write the switch statement: For task 1, display the message "Task 1 process" For task 2, display the message "Task 2 process" For task 3, display the message "Task 3 process" For task 0, display the message "Terminate the program" The do.. while loop ends when users select 0 from the menu 3. Write a for loop that displays the following set of numbers: 4, 7, 11, 16,22, 29, 38, 47, 57, 68, 80, 93 107, 122,138, 155, 173, 192, 222, 243 (DO NOT USE ARRAY FOR THIS QUESTION) Write code that does the following: Opens a file named numbers.txt, uses a loop to write the odd numbers from 1 through 200 to the file and then close the file 4. Write the code that does the following: Open the file numbers.txt created in the question 4 Read all of the numbers from the file Count how many numbers in the file (store in the variable count) add all these numbers (store in the variable sum) close the file numbers.txt display the message 5. There are count numbers Sum of them is: sum

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

Step: 3

blur-text-image

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions