Question

In: Computer Science

Develop an Algorithm and java program using Design Recipe for the following problems. Draw a flowchart...

Develop an Algorithm and java program using Design Recipe for the following problems.

Draw a flowchart to compute the largest and smallest of 4 numbers

: Write a Java Program for the above flowchart, use methods(functions), and nested if-else statements. Take input from the user using the Scanner object. Use separate methods to compute the Largest and Smallest of the numbers. Method 1 Name: findLargest(param 1, param 2, param 3, param 4) Method 2 Name: findSmallest(param 1, param 2, param 3, param 4)

Solutions

Expert Solution

JAVA PROGRAM

import java.util.*;
import java.util.Scanner;

public class Main
{
   public static void main(String[] args)
   {
   Scanner sc = new Scanner(System.in);
   int num1,num2,num3,num4;
  
   System.out.println("Enter Numbers: ");
   //reads input from user
   num1 = sc.nextInt();
   num2 = sc.nextInt();
   num3 = sc.nextInt();
   num4 = sc.nextInt();
  
   // checks the condition for largest number
   if(num1 > num2 && num1 > num3 && num1 > num4)
   {
   System.out.println("Largest Number: "+num1);
     
   }
   else if(num2 > num1 && num2 > num3 && num2 > num4){
   System.out.println("Largets Number: "+num2);
   }
else if(num3 > num1 && num3 > num2 && num3 > num4)
{
System.out.println("Largest Number: "+num3);
}
else{
System.out.println("Largest Number: "+num4);
}
  
//checks the condition for Smallest Numbers
if(num1 < num2 && num1 < num3 && num1 < num4)
   {
   System.out.println("Smallest Number: "+num1);
   }
   else if(num2 < num1 && num2 < num3 && num2 < num4)
   {
   System.out.println("Smallest Number: "+num2);
   }
else if(num3 < num1 && num3 < num2 && num3 < num4)
{
System.out.println("Smallest Number: "+num3);
}
else
{
System.out.println("Smallest Number: "+num4);
}
  
  
   }
}

OUTPUT


Related Solutions

PROGRAM MUST BE WRITTEN IN JAVAFX Develop a program flowchart and then write a menu-driven Java...
PROGRAM MUST BE WRITTEN IN JAVAFX Develop a program flowchart and then write a menu-driven Java program that will solve the following problem. The program uses one and two-dimensional arrays to accomplish the tasks specified below. The menu is shown below. Please build a control panel as follows: (Note: the first letter is shown as bold for emphasis and you do not have to make them bold in your program.) Help SetParams FillArray DisplayResults Quit Upon program execution, the screen...
create flowchart using Flowgorithm and Pseudocode for the following program example:   Design a program for Jones...
create flowchart using Flowgorithm and Pseudocode for the following program example:   Design a program for Jones College. The current tuition is $12,000 per year, and tuition is expected to increase by 5 percent each year. Display the tuition amount for each year over the next five years (use a looping structure).
[15 marks] Draw the flowchart of the following programming problem: You can draw the flowchart using...
[15 marks] Draw the flowchart of the following programming problem: You can draw the flowchart using a drawing tool, or draw the flowchart on a piece of paper, take a picture, insert it here or save it in the submission folder The program reads an unspecified number of integers until a zero is entered. While the program reads each number it counts the number of positive numbers and the number of negative numbers that have been entered and sum up...
Develop an algorithm and a  flowchart for the following: Problem Specification:      Jennifer Camacho It’s the owner...
Develop an algorithm and a  flowchart for the following: Problem Specification:      Jennifer Camacho It’s the owner of Amazing Toyota, a company that sells this type of cars in Puerto Rico. She wants a program that displays the amount of salespersons commission. Some companies use a fixed rate to calculate the commission, while others (like Amazing Toyota) use a rate that varies with the amount of sales. If The salesperson sales $15,000 in one moth his commission will be a 2...
Design a program using a flowchart or pseudocode that accepts a person’s loyalty card number and...
Design a program using a flowchart or pseudocode that accepts a person’s loyalty card number and amount spent in the store last month. Display the data only if the customer is a high spender – a person who spent more than $1000 in the store. A program that accepts customer info continuously until a sentinel value is entered and displays a list of high spenders.
DESIGN A FLOWCHART IN FLOWGORITHM AND WRITE THE PSEUDOCODE Number Analysis Program Design a program that...
DESIGN A FLOWCHART IN FLOWGORITHM AND WRITE THE PSEUDOCODE Number Analysis Program Design a program that asks the user to enter a series of 20 numbers. The program should store the numbers in an array and then display the following data: The lowest number in the array. The highest number in the array. The total of the numbers in the array. The average of the numbers in the array. PLEASE AND THANK YOU
CSC MUST BE IN JAVA Design a program as per the following information using the accompanying...
CSC MUST BE IN JAVA Design a program as per the following information using the accompanying data file. Here is the datafile: sodaSalesB.dat Make sure the program compiles and that you include pseudo code. The assignment is worth 100 points.  (Lack of pseudo code will cost you 15pts) You have been asked to produce the report below. This report will tell the company how sales are going. You will read the file named sodasales.dat The values are the brand name, number...
DESIGN A FLOWCHART IN THE APPLICATION FLOWGORITHM Exercise called: Number Analysis Program Design a program that...
DESIGN A FLOWCHART IN THE APPLICATION FLOWGORITHM Exercise called: Number Analysis Program Design a program that asks the user to enter a maximum of 20 numbers. The program should store the numbers in an array and then display the following data: 1-The lowest number in the array. 2-The highest number in the array. 3-The total of the numbers in the array. 4-The average of the numbers in the array. PLEASE AND THANK YOU
I need the Java Code and Flowchart for the following program: Suppose you are given a...
I need the Java Code and Flowchart for the following program: Suppose you are given a 6-by-6 matrix filled with 0s and 1s. All rows and all columns have an even number of 1s. Let the user flip one cell (i.e., flip from 1 to 0 or from 0 to 1) and write a program to find which cell was flipped. Your program should prompt the user to enter a 6-by-6 array with 0s and 1s and find the first...
Write a Python program that: Create the algorithm in both flowchart and pseudocode forms for the...
Write a Python program that: Create the algorithm in both flowchart and pseudocode forms for the following requirements: Reads in a series of positive integers,  one number at a time;  and Calculate the product (multiplication) of all the integers less than 25,  and Calculate the sum (addition) of all the integers greater than or equal to 25. Use 0 as a sentinel value, which stops the input loop. [ If the input is 0 that means the end of the input list. ]...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT