Assignment_Two
Assignment_Two
Inputs must be accepted in the exact order shown in the example I/O windows
No extra text must be included as part of your output. For example if the result you
want to display is 5, just display the number 5. Do NOT display
“The result is 5” since the grading software cannot match it with the expected output.
1. Write a program that accepts two integers from the user and displays their
greatest common divisor (GCD) if they have any. Otherwise it should display 1.
Some examples of the console I/O for your program is shown below:
Enter First Number: 10
Enter Second Number: 15
5
Write a program that takes a values of x and n as inputs from the user and outputs this
sum. A sample of input/output if shown below
Hints:
Use variables of type double to store the factorials (or arrange your calculation to
avoid any direct calculation of factorials); otherwise, you are likely to produce integer
overflow, that is, integers larger than Java allows.
Also, you will have a neater solution if you first define a function that takes a value of
n and returns its factorial. You can add your function below the main method as
follows:
public static void main(String[] args){
Once you run your program, check how close your output is with a pre-computed
value.