Answer to Question #240478 in Java | JSP | JSF for Selma Shigwedha

Question #240478
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-22T06:28:50-0400

Pseudocode:

a := read()
b := read()
c := read()

a := a + 1
c := c - 2

sum := a + b
sub := b - c
mul := a * c

res := (sum + sub + mul) / 3

print(res)

Flowchart:




Code in Java:

import java.util.Scanner;

public class Q240478 {
  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 -= 1;
    b += 2;
    
    int sum = a + b;
    int sub = b - c;
    int mult = a * c;

    System.out.println((sum + sub + mult) / 3);
    
    return 0;
  }
}

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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS