Answered step by step
Verified Expert Solution
Question
1 Approved Answer
help and explain pls 1. Write a program that uses a do-while loop to print the squares of numbers read from the user until they
help and explain pls
1. Write a program that uses a do-while loop to print the squares of numbers read from the user until they enter the number 0. Do not print the final square of 0 (hint: use a nested control structure). 2. Write a program that reads an integer from the user and then prints a "times table" for the numbers from 1 to the given integer (inclusive). That is, for input n, you would print a table of n rows (lines) each with n columns, where the cell at row i and column j contains the value i x j. You do need separate rows, but don't worry about the columns lining up nicely. 3. Write a program that does the following repeatedly: Asks the user for three numbers. . If all three numbers are 0, the program should finish. Otherwise, print the numbers from the first number to the second incrementing by the third. Repeat. 4. The alternating harmonic series is the following: Write a program that asks the user for a number n and then calculates and prints the sum of the first n terms of the sequence. Try your program with n equal to 10, 100, and 1000. Compare to the value of Math.log (2). Hints: You'll need to use a double for the sum, and be sure you don't use integer division for the individual terms. You'll also need to switch between addition and subtraction. I can think of two ways (one using a variable that changes value and one using a conditional)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started