Question: From the code I wrote can you modify the program to do the following Prompt the user to input two integers: lower and upper (lower

From the code I wrote can you modify the program to do the following

Prompt the user to input two integers: lower and upper (lower must be less than upper).

Use a for loop to find and output all the multiples of 3 between lower and upper on the screen and write each number into a text file lab3data.txt. Separate each number by a space character.

Add statements to find the total number of multiples of 3 between lower and upper and output it on the screen.

Use a while loop to read all the numbers from lab3data.txt which you just wrote data in, find their sum, and output all the numbers and the sum on the screen.

Write loops to print out the following pattern:

From the code I wrote can you modify the program to do

import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Scanner;

public class Lab3 { public static void main(String [] args) throws FileNotFoundException{ int lower, upper; Scanner keyboard = new Scanner (System.in); System.out.println("Enter a lower bound integer: "); lower = keyboard.nextInt(); System.out.println("Enter an upper-bound integer: "); upper = keyboard.nextInt(); File file = new File("lab3data.txt"); PrintWriter outfile = new PrintWriter(file); System.out.println(lower); outfile.println(lower); //for loop outfile.close(); //Task 4 Scanner infile = new Scanner (file); int num = infile.nextInt(); System.out.println("Reading from file ..."+ num); infile.close(); } }

%%%%% % % %% % %% %

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!