Question
Asked Oct 12, 2019
54 views

Translate the following pseudocode for finding the minimum value from a set of inputs into a Java program.
Set a Boolean variable “first” to true.
While another value has been read successfully
If first is true
Set the minimum to the value just read
Set first to false
Else if the value is less than the minimum
Set the minimum to the value
Print the minimum

check_circle

Expert Answer

Java program to find the minimum value

import java.util.Scanner;

 

public class Program

{

     Public static void main(String args[])

     {

          Scanner input = new Scanner(System.in);

          boolean first = true;

          double minimum = Double.MAX_VALUE;

          while(input.hasnextDouble())

          {

              double newDouble = input.nextDouble();

              if(first)

              {

                   minimum = newDouble;

     ...

help_outline

Image Transcriptionclose

import java.util.Scanner; public class Program Public static void main(String args[]) Scanner input = new Scanner(System.in) boolean first= true; double minimum = Double.MAX_VALUE; while (input.hasnextDouble () ) input.nextDouble ( ) ; double newDouble if (first) minimum = newDouble; false; first } else if (newDouble < minimum) minimum = neWDouble; } System.out.println("The minimum value is", minimum); input.close() } } }

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: Programming Question: Write a program in MIPS assembly language that asks the users to enter a value...

A:  Code which is written in MIPS assembly language is shown below-

question_answer

Q: What is it when they say 4g or 5g phone network

A: The usage of 4G or 5G defines that the mobile phone includes 4G or 5G network for the communication....

question_answer

Q: The question is asking for me to "Design a modular program that asks how many tickets for each class...

A: AS per Question,Class A Seat Cost is 15$Class B Seat Cost is 12$Class C Seat Cost is 9$And we need t...

question_answer

Q: Code needed for the following: Use the final numerical grade to look up the corresponding letter gra...

A: This C++ program obey the following rubrics: -In main method – Declaring and initializing the variab...

question_answer

Q: In JavaScript, how can you validate a user’s input to make sure it is both a number and between 20 a...

A: JavaScriptitis a web programing language.it is a cross- platform language.Its code is integrated wit...

question_answer

Q: Using Java Eclipse IDE  (Average an array) Write two overloaded methods that return the average o...

A: Program Instructions:Take 10 double values using scanner class in an array.Call the method average w...

question_answer

Q: Given the following snippet of C++ code: int int1 = -125;unsigned int uInt1 = int1;float float1 = in...

A: ConceptWhenever a negative number is assigned to a variable of any datatype, that number is first co...

question_answer

Q: in python 2. Now write a program named filereader.py that reads and displays the data in friends.txt...

A: The following python program is created that reads and displays data in a file named as friends.txt ...

question_answer

Q: (check all that apply) Which of the following is true about constraint names?A) it can be used for D...

A: A) it can be used for DBA to identify a constraint easily:Yes. Constraints are the rules that are ap...