Question

I need help with the following homework : Write a program that accepts an integer input...

I need help with the following homework :

  1. Write a program that accepts an integer input from the user and display the least number of combinations of 200s, 100s, 50s, 20s, 10s, 5s, and 1s.

[Test your solution using this samples]

  1. Input: 250

Output: 1x200s, 1x50s

  1. Input: 1127

Output: 5x200s, 1x100s, 1x20s, 1x5s, 2x1s

  1. Input: 1127

Output: 5x200s, 1x100s, 1x20s, 1x5s, 2x1s

  1. Input: 19

Output: 1x10s, 1x5s, 4x1s

[Hints]

  • Use division to determine the number of occurrence of each element (i.e. 200, 100) in the input (e.g. Given 500 if we divide it by the largest number possible; which is 200; we will get 2. Therefore, there are 2x200s.)
  • Use subtraction to determine the remaining value of the input. (e.g. In the 500 example, since there are 2x200s, we still have 100 to process. The 100 came from 500 – (2*200) = 100.)
  • Use the next largest number possible (i.e. 100) to check the number of occurrence. Continue until the remaining value of the input is zero.

2. On the second page, draft a flowchart representation of your solution. Use your listed Technical Work Items as your guide.

3. On the last page of your solution, write a translation of your flowcharts to pseudocodes.

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

import java.util.*;
public class Number {
public static void main(String [] args){
   Scanner scan=new Scanner(System.in);
   int num= scan.nextInt();
   if(num/200!=0)
   {
       System.out.print(num/200+"x200s, ");
       num=num-((num/200)*200);
   }
   if(num/100!=0)
   {
       System.out.print(num/100+"x100s, ");
       num=num-((num/100)*100);
   }
   if(num/50!=0)
   {
       System.out.print(num/50+"x50s, ");
       num=num-((num/50)*50);
   }
   if(num/20!=0)
   {
       System.out.print(num/20+"x20s, ");
       num=num-((num/20)*20);
   }
   if(num/10!=0)
   {
       System.out.print(num/10+"x10s, ");
       num=num-((num/10)*10);
   }
   if(num/5!=0)
   {
       System.out.print(num/5+"x5s, ");
       num=num-((num/5)*5);
   }
   if(num!=0)
   {
       System.out.println(num+"x1s");
   }   
}
}

Add a comment
Know the answer?
Add Answer to:
I need help with the following homework : Write a program that accepts an integer input...
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
  • 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....

  • need help with python program The objectives of this lab assignment are as follows: . Input...

    need help with python program The objectives of this lab assignment are as follows: . Input data from user Perform several different calculations Implement conditional logic in loop • Implement logic in functions Output information to user Skills Required To properly complete this assignment, you will need to apply the following skills: . Read string input from the console and convert input to required numeric data-types Understand how to use the Python Modulo Operator Understand the if / elif /...

  • //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which...

    //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming: 1. Given an input file with text and a list of words, find and replace every use of these blacklisted words with the string...

  • In this homework, you will design a program to perform the following task: Write a program...

    In this homework, you will design a program to perform the following task: Write a program that would allow a user to enter student names and Final grades (e.g. A,B,C,D,F) from their courses. You do not know how many students need to be entered. You also do not know how many courses each of the students completed. Design your program to calculate the Grade Point Average (GPA) for each student based on each of their final grades. The program should...

  • JavaScript - I need help formulating executable code for the following problem. 7.15 The process of...

    JavaScript - I need help formulating executable code for the following problem. 7.15 The process of finding the largest value (i.e., the maximum of a group of values) is used frequently in computer applications. For example, a script that determines the winner of a sales contest would input the number of units sold by each sales person. The salesperson who sells the most units wins the contest. Write a pseudocode ode algorithm and then a script that inputs a series...

  • write the solution of the program by python 3 language : I need the program using...

    write the solution of the program by python 3 language : I need the program using list : The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups. Meanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime. If there is no police officer free (isn't busy with crime) during the occurrence of a...

  • python program sample output Problem 3 (Taking User Input) Write a function called userGuess(n) that takes...

    python program sample output Problem 3 (Taking User Input) Write a function called userGuess(n) that takes an integer n as an argument. This function should display n to the user and prompt them to enter the number num that is the largest power of 2 less than or equal to n. Have your function return the user's input num (it will be used in the next problem) Problem 4 (Making a Game) Finally, create a main() function for your program....

  • PYTHON I need help with this Python problem, please follow all the rules! Please help! THANK...

    PYTHON I need help with this Python problem, please follow all the rules! Please help! THANK YOU! Bonus Question Implement an efficient algorithm (Python code) for finding the 11th largest element in a list of size n. Assume that n will be greater than 11. det find 11th largest numberlissy Given, lissy, a list of n integers, the above function will return the 11th largest integer from lissy You can assume that length of lissy will be greater than 11....

  • (C++ programming) Need help with homework. Write a program that can be used to gather statistical...

    (C++ programming) Need help with homework. Write a program that can be used to gather statistical data about the number of hours per week college students play video games. The program should perform the following steps: 1). Read data from the input file into a dynamically allocated array. The first number in the input file, n, represents the number of students that were surveyed. First read this number then use it to dynamically allocate an array of n integers. On...

  • Program is in C++. Write a function named wordStatsPlus that accepts as its parameter a string...

    Program is in C++. Write a function named wordStatsPlus that accepts as its parameter a string holding a file name, opens that file and reads its contents as a sequence of words, and produces a particular group of statistics about the input. You should report: the total number of lines; total number of words; the number of unique letters used from A-Z, case-insensitively, and its percentage of the 26-letter alphabet; the average number of words per line (as an un-rounded...

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