Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The first picture is the task. The others are just some information that may be

ID: 3751626 • Letter: T

Question

The first picture is the task. The others are just some information that may be needed. Thanks.

Tasks Write a program that prints Pac and calls two methods: 1. Print a table showing the powers of a numbei entered by the user. The user should also be asked to enter the maximum exponent 2. Print a table showing the results of the remainder operation, varying both numerator and denominator. The user should be asked to enter the maximum denominator and numerator Here is an example of what your output should look like (user input is in bold and underlined) Details The Console You will need to use Scanner to obtain input from the keyboard. You should declare a class constant of type Scanner named coNsOLE at the beginning of your class; you should store new Scanner(System.in) in CONSOLE See examples in the Chapter 2 lecture notes and in the Laboratory 2 assignment.

Explanation / Answer

import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Solution {
public static void main(String[] args) {
//input
Scanner CONSOLE = new Scanner(System.in);
  
//power table
System.out.println("Enter the base: ");
int base = CONSOLE.nextInt();
System.out.println("Enter the maximum exponent: ");
int exponent = CONSOLE.nextInt();
  
System.out.println("The base is "+ String.valueOf(base) +" and the maximum exponent is "+String.valueOf(exponent));
  
System.out.println("");
System.out.println("Powers of "+String.valueOf(base));
System.out.println("");
System.out.println("x "+String.valueOf(base)+"^x");
  
for(int i=0;i<=exponent;i++){
System.out.println(String.valueOf(i)+" "+String.valueOf((int)Math.pow(base,i)));
}
  
System.out.println("");
  
//divisor and reminder table
System.out.println("Enter the maximum numerator: ");
int numerator = CONSOLE.nextInt();
System.out.println("Enter the maximum denominator: ");
int denominator = CONSOLE.nextInt();
  
System.out.println("The maximum numerator is "+ String.valueOf(numerator) +" and the maximum denominator is "+String.valueOf(denominator));
  
System.out.println("");
System.out.println("Reminders");
System.out.println("");
String title = "n ";
for(int i=0;i<denominator;i++){
title = title + "n%"+String.valueOf(i+1)+" ";
}
System.out.println(title);
  
for(int i=1;i<=numerator;i++){
String str = String.valueOf(i)+" ";
for(int j=1;j<=denominator;j++){
str = str + String.valueOf(i%j)+" ";
}
System.out.println(str);
}
}
  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote