Question

Please draw a flow chart for each method please and thank you.

Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of inte1 import java.util.Scanner; 2 3 public class Prog7_outputValues_method { 4 5 public static void main(String[] args) { 6 7 8 9

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Java code for above problem

import java.util.Scanner;
public class Prog7_outputValues_method
{
   public static void main(String args[])
   {
       Scanner scnr=new Scanner(System.in);
       int arrSize=scnr.nextInt();
       int [] myArr=new int[arrSize];
       getUserValues(myArr,arrSize,scnr);
       int upperThreshold=scnr.nextInt();
       outputIntsLessThanOrEqualToThreshold(myArr,arrSize,upperThreshold);
   }
   public static void getUserValues(int myArr[],int arrSize,Scanner scnr)
   {
       for(int i=0;i<arrSize;i++)
       {
           myArr[i]=scnr.nextInt();
       }
   }
   public static void outputIntsLessThanOrEqualToThreshold(int myArr[],int arrSize,int upperThreshold)
   {
       for(int i=0;i<arrSize;i++)
       {
           if(myArr[i]<=upperThreshold)
           {
               System.out.print(myArr[i]+" ");
           }
       }
       System.out.println();
   }
}

Sample output

5 50 66 140 200 75 100 50 60 75

Flowchart for getUserValues() method:

Start parameters myArt I, are Size scar 1-0 NO is arrsize MES get input from wer & Store in my Arr[i] 1 i=it I Stop

Flowchart for outputIntsLessThanOrEqualToThreshold() method

Start parameters my Arol ] ArtSite, upperThreshold No Karesine YES NO my Arsti]<= upper Threshold YES pont (ry Arrli]) i= it!

Mention in comments if any mistakes or errors are found. Thank you.

Add a comment
Know the answer?
Add Answer to:
Please draw a flow chart for each method please and thank you. Write a program that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • IN JAVA Write a program that first gets a list of integers from input. The input...

    IN JAVA Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, which indicates a threshold. Output all integers less than or equal to that last threshold value. Assume that the list will always contain fewer than 20 integers. Ex: If the input is: 5 50 60 140 200 75 100 the output is: 50 60 75...

  • Write a program that first gets a list of integers from the input and adds them...

    Write a program that first gets a list of integers from the input and adds them to an array. The input begins with an integer indicating the number of integers that follow (Your program should work for any size of the array). Then, get the last value from the input, and output all integers less than or equal to that value by iterating through the array. Ex: If the input is: Enter the number of integers: 5 Enter integer 1:...

  • Write a program that first gets a list of integers from input. The input begins with...

    Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, and output all integers less than or equal to that value. Ex: If the input is: 5 50 60 140 200 75 100 the output is: 50 60 75 The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75....

  • Coral Language Please to thanks Write a program that first gets a list of 5 integers...

    Coral Language Please to thanks Write a program that first gets a list of 5 integers from input. Then, get another value from the input, and output all integers less than or equal to that value. Ex: If the input is 50 60 140 200 75 100, the output is: 50 60 75 For coding simplicity, follow every output value by a space, including the last one. Then, output a newline. Such functionality is common on sites like Amazon, where...

  • *Coral Language* Write a program that first gets a list of six integers from input. The first five values are the intege...

    *Coral Language* Write a program that first gets a list of six integers from input. The first five values are the integer list. The last value is the upper threshold. Then output all integers less than or equal to the threshold value. Ex: If the input is 50 60 140 200 75 100, the output is: 50 60 75 For coding simplicity, follow every output value by a space, including the last one. Such functionality is common on sites like...

  • in python and can you tell me why i am wrong? Thank you ZyBooks Python M...

    in python and can you tell me why i am wrong? Thank you ZyBooks Python M X zy cS 171: Computer x zy 11.9. LAB: Output x C Write A Program 1 x Slack | Hiu Nguy TG Python Program t x p ython - Getting x +. - 5 x € → e l earn.zybooks.com/zybook/DREXELCS171 Winter2020/chapter/11/section/9 Help/FAQ Kuanyu Lai - = zyBooks Bake My library > CS 171: Computer Programming home> > 11.9: LAB: Output values in a list...

  • 1. Assign numMatches with the number of elements in userValues that equal matchValue. userValues has NUM_VALS...

    1. Assign numMatches with the number of elements in userValues that equal matchValue. userValues has NUM_VALS elements. Ex: If userValues is {2, 1, 2, 2} and matchValue is 2 , then numMatches should be 3. Your code will be tested with the following values: matchValue: 2, userValues: {2, 1, 2, 2} (as in the example program above) matchValue: 0, userValues: {0, 0, 0, 0} matchValue: 10, userValues: {20, 50, 70, 100} What i am given: import java.util.Scanner; public class FindMatchValue...

  • How do I add the space that this Zybooks code keeps asking me to add? 5.13...

    How do I add the space that this Zybooks code keeps asking me to add? 5.13 LAB: Output numbers in reverse Write a program that reads a list of integers, and outputs those integers in reverse. The input begins with an integer indicating the number of integers that follow. For coding simplicity, follow each output integer by a space, including the last one. Assume that the list will always contain fewer than 20 integers. Ex: If the input is: 5...

  • 3.16 LAB: Output range with increment of 10 Write a program whose input is two integers,...

    3.16 LAB: Output range with increment of 10 Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 10 as long as the value is less than or equal to the second integer. Ex: If the input is: -15 30 the output is: -15 -5 5 15 25 Ex: If the second integer is less than the first as in: 20 5 the output is: Second integer can't be less than...

  • Answer in JAVA 1. Complete the method definition to output the hours given minutes. Output for...

    Answer in JAVA 1. Complete the method definition to output the hours given minutes. Output for sample program: 3.5 import java.util.Scanner; public class HourToMinConv {    public static void outputMinutesAsHours(double origMinutes) {       /* Your solution goes here */    }    public static void main (String [] args) {       Scanner scnr = new Scanner(System.in);       double minutes;       minutes = scnr.nextDouble();       outputMinutesAsHours(minutes); // Will be run with 210.0, 3600.0, and 0.0.       System.out.println("");    } } 2....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT