Answer to Question #233859 in Java | JSP | JSF for usman

Question #233859

Write a program that asks the user to enter three positive integer value; number, start, end and

Silicon Value, and then prints the Silicon table of the number from the starting number to the ending

number. After printing the table, our program should ask the user whether he or she wishes to perform

the operation again. If so, the loop should repeat; otherwise it should terminate.

Use a character input of y or Y to repeat, and n and N to terminate the loop. No break statement is

allowed.


NOTE: Perform input validation so that all numbers must be greater than 0 and the “start” number

should be less than “end” number.

NOTE: Silicon Number is multiplied with iteration counter as shown in the table below


:


Enter a number: 5

Enter starting value: 3

Enter ending value: 7

Enter silicon value: 9


Silicon Table:

5 * 3 * 9 = 135

5 * 4 * 18 = 360

5 * 5 * 27 = 675

5 * 6 * 36 = 1080

5 * 7 * 45 = 157

Enter a number: 6

Enter starting value: 5

Enter ending value: 6

Enter silicon value: 8




1
Expert's answer
2021-09-06T23:57:27-0400
import java.util.Scanner;
import java.lang.*;
public class Main
{
    public static void Silicontable(int number, int start, int end,int silicon_value){
       int s=silicon_value;
		for(int i=start; i<=end;i++){
		    System.out.println(number+" * "+i+" * "+silicon_value+" = "+number*i*silicon_value);
		    silicon_value+=s;
		} 
    }
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		boolean f=true;
		int number, start, end, silicon_value;
		char c;
		while(f==true){
		    System.out.println("Enter a number: ");
    		number=in.nextInt();
    		System.out.println("Enter starting value: ");
    		start=in.nextInt();
    		System.out.println("Enter ending value: ");
    		end=in.nextInt();
    		System.out.println("Enter silicon value: ");
    		silicon_value=in.nextInt();
    		Silicontable(number,start,end, silicon_value);
    		
    		System.out.println("Do you want to perform another operation? y/n");
    		c=in.next().charAt(0);
    		if (c=='y' || c=='Y')
    		    f=true;
    		else if(c=='n' || c=='N')
    		    f=false;
		}
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS