QUESTION 12
Write a program that would prompt the user to enter an integer. The program then would displays a table of squares and cubes from 1 to the value entered by the user. The program should prompt the user to continue if they wish. Name your class NumberPowers.java, add header and sample output as block comments and uploaded it to this link.
Use these formulas for calculating squares and cubes are:
Assume that the user will enter a valid integer.
The application should continue only if the user enters “y” or “Y” to continue.
Sample Output
Welcome to the Squares and Cubes table Enter an integer: 4 Number Squared Cubed ====== ======= ===== 1 1 1 2 4 8 3 9 27 4 16 64 Continue? (y/n): y Enter an integer: 7 Number Squared Cubed ====== ======= ===== 1 1 1 2 4 8 3 9 27 4 16 64 5 25 125 6 36 216 7 49 343 Continue? (y/n): n
ANSWER:-
import java.util.*;
class NumberPowers
{
public static void main (String[] args)
{
int n;
char ch;
System.out.println("Welcome to the
Squares and Cubes table");
Scanner sc=new
Scanner(System.in);
do
{
System.out.println("\nEnter a
integer : 4");
n=sc.nextInt();
System.out.println("\nNumber
Squared Cubed");
System.out.println("====== =======
=====");
for(int i=1;i<=n;i++)
System.out.println(i+" "+i*i+"
"+i*i*i);
System.out.println("\nContinue?(y/n): n");
ch=sc.next().charAt(0);
}while(ch=='y' || ch=='Y');
}
}
OUTPUT:-
Welcome to the Squares and Cubes table Enter a integer : 4 Number Squared Cubed ====== ======= ===== 1 1 1 2 4 8 3 9 27 4 16 64 Continue?(y/n): n
// If any doubt please comment
QUESTION 12 Write a program that would prompt the user to enter an integer. The program...
Write a java program that asks the user to enter an integer. The program should then print all squares less than the number entered by the user. For example, if the user enters 120, the program should display 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, and 100.
Write a Python program to prompt the user for an integer number. Assign this integer to a variable X. Then assign a variable Y to the X**3 (X to the power 3). Finally, assign the variable Z to the square root of Y and print the values of X, Y, and Z as shown in the example below. Use main() function to define and call the program. Example: Enter an integer number: 3 X = 3 if Y=X**3 then Y...
Write a Java program to prompt for inputting an integer N, then enter N integers (a loop is needed), print the numbers user entered, and the amount of even and odd numbers (zero is even number). (1) Prompt for the user to input an integer and output the integer. (1 pts) Enter an integer: You entered: 5 (2) Prompt for the user to input N integers, output the numbers entered and the amount of even and odd numbers (9 pts)...
(1) Output the user's input. (2 pts) Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs. Enter integer: 4 You entered: 4 (2) Extend to output the input squared and cubed. Hint: Compute squared as userNum * userNum. (2 pts) Enter integer: 4 You entered: 4 4 squared is 16 And 4 cubed is 64!! (3) Extend to get a second user input into userNum2. Output sum and product. (1 pt) Enter integer: 4 You entered: 4 4 squared is 16 And 4 cubed is 64!! Enter another integer: 5 4 + 5 is 9 4 * 5 is 20
the author's pseudocode
it follows this template
3 Design the logic for a program for Nos Encanta Tu Interés credit card company that a) Allows the user to enter their name, credit card number, beginning balane and monthly interest rate b) For the next full year (12 months), 1. Outputs the month number and the balance at the beginning of the month 2. Allows the user to enter the amount of their payment, and the amount of their purchases for...
Write a programming java that prints the sum of cubes. Prompt for and read two integer values from the user and print the sum of each value raised to the third power, i.e., (?3+?3). Sample output: (user input) Enter x as an int: 3 Enter y as an int: 4 (3^3) + (4^3) = 91
Write python program using IDLE Write a full program that asks the user to enter his/her name then repeatedly ask to enter the temperature in Fahrenheit and convert it to Celsius, the program should then prompt the user if he/she wants to continue or exit the program. The formula for the conversion is: °C = (°F - 32) x 5/9 The program should use a function for the conversion. An Example of a sample run should appear on the screen...
Write a Java program that performs these operations Prompt the user to enter a low height in feet (an integer) Prompt the user to enter a high height in feet (an integer) Prompt the user to enter a low weight in pounds (an integer) Prompt the user to enter a high weight in pounds (an integer) Print a table of Body Mass Index (BMI) for the heights and weights entered, ranging from the low height to the high height (inclusive),...
write in python idle Write full program that asks the user to enter his/her name then repeatedly ask to enter the temperature in Fahrenheit and convert it to Celsius, the program should then prompt the user if he/she wants to continue or exit the program. The formula for conversion is: °C = (°F - 32) x 5/9 The program should use a function for the conversion. An Example of a sample run should appear on the screen like the text...
Write a c++ complete program to meet the specifications. The program should prompt the user for a positive integer. The program should print a message whether the integer is even or odd. The looping should end when the user enters a negative number. The negative number will not be tested for even or odd. The program will print out a message of how many numbers were entered (not counting the negative number) and how many even and odd numbers were...