1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ad-work [718]
3 years ago
9

1. Write a function that will ask the user to enter a value in dollars. The function should calculate and display the equivalent

number of pennies, nickels, dimes, and quarters. Acceptable values are those which when multiplied by 100 will be exactly divisible by 50 (100*value must be exactly divisible by 50). Write a caller main function to call your function.
Computers and Technology
1 answer:
julia-pushkina [17]3 years ago
3 0

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

   

    valueInDollars();

}

   public static void valueInDollars() {

       double currentMoney, quarters, dimes, nickels, pennies;

       Scanner input = new Scanner(System.in);

       

       System.out.print("Enter a value in dollars: ");

       currentMoney = input.nextDouble();

       currentMoney *= 100;

       quarters = (int)currentMoney / 25;

       currentMoney = currentMoney % 25;

       

       dimes = (int)currentMoney / 10;

       currentMoney = currentMoney % 10;

       

       nickels = (int)currentMoney / 5;

       currentMoney = currentMoney % 5;

       

       pennies = currentMoney;

       

       System.out.print("Quarters: " + quarters + "\n" + "Dimes: " + dimes + "\n" + "Nickels: " + nickels + "\n" + "Pennies: " + pennies);

   }

}

Explanation:

<u>Inside the function:</u>

- Declare the variables

- Ask the user for a value in dollars

- Multiply that value by 100

- Find the amount of quarters, dimes, nickels, and pennies

- Print the values

<u>Inside the main:</u>

- Call the function

You might be interested in
Can someone please help me? I have no clue what any of this is and how I'm going to find out 15 examples of these. It's due some
zvonat [6]
I am not really sure sorry
7 0
3 years ago
3.5 Code Practice: Question 1 edhesive
klio [65]

Answer:

x = int(input("What grade are you in? "))

if(x == 9):

  print("Freshman")

 

elif(x == 10):

  print("Sophomore")

 

elif(x == 11):

  print("Junior")

 

elif(x == 12):

  print("Senior")

 

else:

  print("Not in High School")

Explanation:

4 0
3 years ago
Which statement is true? Select 3 options.
irina1246 [14]

Answer:

The statements which are true are;

  • A user-defined data type can include other user-defined data types
  • A user-defined data type is defined using a class
  • A user-defined data type can include a list

Explanation:

A user-defined data type (UDT) is a datatype that is defined and derived by the use of the datatypes which preexist including existing user-defined datatypes and the built-in datatypes

It is therefore true that a user-defined data type can include other user-defined data types

A class is a user-defined data type that contains both its member data and member functions, that can be used when an instance of the class is first created

Therefore, a user-defined data type is defined using a class

In a user-defined data type, a variable has actual data within it which can include an array or list

Therefore a user-defined data type can include a list.

3 0
2 years ago
Read 2 more answers
Task 04
aleksley [76]

Answer:

are u sure this is the right question?

Explanation:

7 0
1 year ago
The ____________________ chip handles the functions of the keyboard controller.
RoseWind [281]
I think the ROM chip handles the functions of a keyboard controller.
7 0
3 years ago
Other questions:
  • All of the following are qualities of an aprenticeship except
    12·1 answer
  • 1. Create a detail report that will display all SCR courses in alphabetical order, with the course name and the instructor name
    6·1 answer
  • Netflix shows to watch?
    11·2 answers
  • In which situations would it be most helpful to filter a form? Check all that apply.
    8·1 answer
  • What techniques overcome resistance and improve the credibility of a product? Check all that apply.
    8·1 answer
  • he wants to customize the operating system to meet his needs. what types of tools should he use, and what can he do with each?
    6·1 answer
  • What is the name of the device protected by a digital certificate?
    10·1 answer
  • Where is the flash drive listed in a windows 7 save as dialog box?
    9·1 answer
  • Each JavaScript command line ends with a(n) ____ to separate it from the next command line in the program.
    5·1 answer
  • What makes a recipe for a meal an example of an algorithm?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!