Computer Science, asked by DograSaab7392, 10 months ago

In the examination,surpana has been asked to write the code for placing a drop-down list in form area. She also asked to indicate any one of the menu items as preselected.Help her in solving the problem

Answers

Answered by aka757489
1

I'm trying to Write the main method of a Java program that has the user enter two integers, i and n. If either integer is less than 2, output “Please enter numbers above 1.” Otherwise, output the n positive multiples of i, separated by spaces.

I'm close but can't figure out how to do display the multiples.

Here's what a sample run should look like:

Enter i: 4

Enter n: 6

6 multiples of 4 are: 8 12 16 20 24 28

import java.util.*;

public class HW5Problem3 {

public static void main (String [] args) {

int i = 0;

int n = 0;

Scanner input = new Scanner(System.in);

System.out.print("Enter i: ");

i = input.nextInt();

System.out.print("Enter n: ");

n = input.nextInt();

if ((i <= 1) || (n <= 1)) {

System.out.println("Please enter numbers above 1");

System.exit(1);

}

System.out.print(n + " multiples of " + i + " are: ");

}

}

Similar questions