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
earnstyle [38]
4 years ago
10

Given four values representing counts of quarters, dimes, nickels and pennies, output the total amount as dollars and cents. Out

put each floating-point value with two digits after the decimal point, which can be achieved as follows: System.out.printf("Amount: $%.2f\n", dollars); Ex: If the input is: 4 3 2 1 where 4 is the number of quarters, 3 is the number of dimes, 2 is the number of nickels, and 1 is the number of pennies, the output is: Amount: $1.41 For simplicity, assume input is non-negative.
LAB ACTIVITY 2.32.1: LAB: Convert to dollars 0/10 LabProgram.java Load default template. 1 import java.util.Scanner; 2 3 public class LabProgram 4 public static void main(String[] args) { 5 Scanner scnr = new Scanner(System.in); 6 7 /* Type your code here. */|| 8 9) Develop mode Submit mode Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box Enter program input (optional) If your code requires input values, provide them here. Run program Input (from above) 1 LabProgram.java (Your program) Output (shown below) Program output displayed here
Computers and Technology
1 answer:
fenix001 [56]4 years ago
7 0

Answer:

Replace /* Type your code here. */ with the following lines of code

int quarter =scnr.nextInt();

int dime = scnr.nextInt();

int nickel = scnr.nextInt();

int penny = scnr.nextInt();

double dollars = quarter * 0.25 + dime * 0.1 + nickel * 0.05 + penny * 0.01;

System.out.printf("Amount: $%.2f\n", dollars);

System.out.print((dollars * 100)+" cents");

Explanation:

The next four lines declare the given currencies as integer

<em>int quarter =scnr.nextInt();</em>

<em>int dime = scnr.nextInt();</em>

<em>int nickel = scnr.nextInt();</em>

<em>int penny = scnr.nextInt();</em>

This line calculates the amount in dollars

<em>double dollars = quarter * 0.25 + dime * 0.1 + nickel * 0.05 + penny * 0.01;</em>

The next two lines print the amount in dollars and cents respectively

<em>System.out.printf("Amount: $%.2f\n", dollars); </em>

<em>System.out.print((dollars * 100)+" cents");</em>

You might be interested in
What is anequality query​
klasskru [66]

In SQL, there are two ways to test for inequality in a query. You can use either the <> or !=

7 0
3 years ago
GuardIN is an IT security firm. It deals with highly secure data for a wide variety of software and e-commerce agreements, trade
jeka57 [31]

Answer:

GuardIN is an IT security firm. It deals with highly secure data for a wide variety of software and e-commerce agreements, trademark licenses, and patent licenses. GuardIN needs a cloud computing option that would allow it to purchase and maintain the software and infrastructure itself. The cloud also needs to be designed in such a way that all users of the organization can access it without any lag. Which cloud computing option would be most suitable for GuardIN?

Explanation:

3 0
3 years ago
What is the function of the command prompt?
yan [13]
The answer is B cause you use it to make commands
6 0
3 years ago
How do computers use logic?
madreJ [45]
They don’t use any logic
8 0
4 years ago
Which option best describes a trustworthy person?
jasenka [17]
<span>A person who babysits your kids or who you tell your secrets to.



A example since you dont have choices</span>
5 0
4 years ago
Read 2 more answers
Other questions:
  • When looking at an object or process to code, it is important to think of as general a solution as possible and consider all the
    13·1 answer
  • 1. What is the global marketplace?
    11·2 answers
  • Which of these components is a part of the central processing unit (CPU) of a computer? A. memory B. storage C. control unit D.
    8·2 answers
  • Which of these network connections would allow your smartphone to sync your photos to your online account? Choose all that apply
    8·1 answer
  • Personality traits such as thoughtfulness, empathy, self-control, and goal orientation belong to the _____ category.
    5·2 answers
  • According to Android’s suggested user interface standards, repeatedly pressing the app icon on an app’s action bar will eventual
    5·2 answers
  • The column boundary, the border to the right of a column, can be dragged until a row is at a desired height. true or false
    14·1 answer
  • Mathematics and modern technology​
    14·1 answer
  • Write a Python program to: ask the user to enter the price of an item. Note: use a while loop to check the validity of the price
    11·1 answer
  • You suspect that a bad video driver is causing a user's system to randomly crash and reboot. Where would you go to identify and
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!