Answer to Question #239022 in Java | JSP | JSF for guru

Question #239022

Given three numbers from user input, decrement the first number by 1 and increment the third number by 2, Then do the magic calculations as follows: get the sum of the first two numbers, deduct the third number from the second and get the product of the first and third number, then sum up the results of the three magic calculations and finally divide you outcome by 3. Sample run 1:

Enter three numbers separated by spaces: 4 2 3

Output: Result of Magic calculations = 5

Sample run 2: Enter three numbers separated by spaces: 2 8 5

Output: Result of Magic calculations = 5

a) Write an Pseudocode to solve the above problem

b) Create a flowchart for the above pseudocode

c) With the help of both your Pseudocode and Flowchart, create a Java program that solves the program as per the given sample out puts and problem description


1
Expert's answer
2021-09-18T17:27:28-0400
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();

        a--;
        c += 2;

        int sum = a + b;
        int sub = b - c;
        int mul = a * c;

        int result = (sum + sub + mul) / 3;

        System.out.println(result);
    }
}


Integer a := readInteger()

Integer b := readInteger()

Integer c := readInteger()


a := a - 1

c := c + 2


Integer sum := a + b

Integer sub := b - c

Integer mul := a * c


Integer resul := (sum + sub + mul) / 3


output(result)



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

SHALOM
26.09.21, 15:33

Really helped me with my assignment. Thank you

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS