
Code language Java
1, Add a print statement to say “Multiplication Table” and then prompt the
user to enter an integer. Your program should then prints “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 × j. You do need separate rows, but don’t worry about the
columns lining up nicely yet.
2. Add a print statement to say “Prime Testing”.
Using the integer entered by the user above, print out all the prime numbers between
2 and the number squared. E.g., if the user types 12 for the multiplication table part,
you should print all the prime numbers that are not larger than 144.
All integers are either prime or composite. A prime number is one that has no integer
factors other than itself or one. Examples are 2, 3, 5, 7, 11, 13, . . .. A composite
number, by contrast, has multiple factors. Examples are 4, 6, 12, 15, 18, 21, . . ..
Testing whether or not a number is prime is an important application of computing
power. One very simple method is to simply check every possible factor from 2 up to
the number in question.
For example, to test whether or not the value 35 is prime, you can test if 35 % 2 ==
0, then if 35 % 3 == 0, then is 35 % 4 == 0, and so on, up until you find a number
that evenly divides 35 or confirm that no such number exists. You must write this
yourself, and cannot use any library methods for primality testing.
3, Add another print statement that says “Infinite Series Test”.
Consider the infinite series
This time you should prompt the user to enter a second integer k, and then calculates
and prints the sum of the first k terms of the sequence. Do not use Math.pow. Instead,
compute the value of 2k
incrementally in your loop. Try your program for different
values of k. Do you notice a trend?

Lets see the solution in the next steps
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

- Using python, please explain 1: A positive integer greater than 1 is said to be prime if it has no divisors other than 1 and itself. A positive integer greater than 1 is composite if it is not prime. Write a program that asks the user to enter an integer greater than 1, then displays all of the prime numbers that are less than or equal to the number entered The program should work as follows: Once the user has entered a number, the program should populate a list with all of the integers from 2 up through the value entered. The program should then use a loop to step through the list. The loop should pass each element to a function that displays the element whether it is a prime number.arrow_forwardA program in javaarrow_forwardIn python, write a code that allows the user to input two non-negative number sequences in increasing order (the numbers entered are always getting bigger, and no number repeats), both terminated by a -1. The size of each sequence can vary (maybe sequence - 1 has four numbers, and sequence - 2 has seven). The output of this code should be a third sequence that is a combination of both sequences 1 and 2 and is sorted in non-decreasing order. Note: Non-decreasing order means there can be a repeated number in the third sequence (see example 1). A strictly increasing order sequence cannot have repeat numbers at all (see example 3). Remember, all input sequences must be in strictly increasing order! please do this using python, only using while loops. NO language of "break" or "len" please. Hint: we can use three separate lists to solve this code.arrow_forward
- In Java: Forms often allow a user to enter an integer. Write a program that takes in a string representing an integer as input, and outputs yes if every character is a digit 0-9. Ex: If the input is: 1995 the output is: yes Ex: If the input is: 42,000 or 1995! the output is: no Hint: Use a loop and the Character.isDigit() function.arrow_forwardIn PYTHON, write a code that allows the user to input two non-negative number sequences in increasing order (the numbers entered are always getting bigger, and no number repeats), both terminated by a -1. The size of each sequence can vary. The output of this code should be a third sequence that is a combination of both sequences 1 and 2 and is sorted in non-decreasing order. Note: Non-decreasing order means there can be a repeated number in the third sequence (see example 1). A strictly increasing order sequence cannot have repeat numbers at all (see example 3). PLEASE do this using PYTHON, ONLY using while loops. NO language of "break", "len" or "True" please. Hint: we can use three separate lists to solve this code.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





