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
lorasvet [3.4K]
3 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:
vesna_86 [32]3 years ago
6 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
Given the following code fragment, what is the data type of roster[9] .name? struct student { string name; double gpa; }; studen
SVETLANKA909090 [29]

roster[50] is an array of "students", so roster[9] is a "student". Therefore, roster[9].name is a string.

3 0
3 years ago
What is one advantage of top-down programming design?
mojhsa [17]

Answer:

Programmers can take advantage of abstraction to focus on specific tasks.

Explanation:

When we excel in some subjects, we can do abstraction in that subject. Abstraction means you understand by the term, and you do not need details of that term. Like you say some tasks will be done by a graphic designer as a project manager, and you do not need to understand at that point what he will be doing, and that is because you can write in a word or few what is going to be the outcome. And hence, the programmers can take advantage of abstraction to focus on specific tasks. And this is the correct option.

5 0
3 years ago
Read 2 more answers
Which method is an easy way to find a short description of a function?
yuradex [85]

Answer:

A...In the Insert Function dialog box, click the function name to get a short description.

Explanation:

would be A

6 0
3 years ago
Read 2 more answers
As a photographer, what will be the driving force behind everything that you produce?
GREYUIT [131]

Answer:

You have to like it to be successful in photography.

Explanation:

8 0
3 years ago
You are studying for a test tomorrow. Your friends invite you to
lapo4ka [179]

Answer: C

Explanation:

7 0
3 years ago
Other questions:
  • "Server Manager will allow you to manage all roles and features installed on any server, and view the status of all your servers
    7·1 answer
  • You just brought a new hard drive for your computer. U plan to use this as a secondary hard drive to store all your uma files. O
    10·1 answer
  • bj;ljfg'cfmb dfl kbslf jflk[gkdblkfd lbrkjlfbbfkjbdfjkbadbjbbkvbk'lbk'blbf;l;lkb lm;flklmkjlvkljvkljvbfbdsjsfbbjjlkbfjklbkfj'lgg
    9·2 answers
  • The action in which a router divides and forwards incoming or outbound message traffic to multiple links is known as
    15·1 answer
  • What do developers do to support software products? explain to users which development process model was used to make the produc
    8·1 answer
  • The introduction of new information technology has a: A. dampening effect on the discourse of business ethics. B. waterfall effe
    14·1 answer
  • Which of the following is the correct binary representation of the number 2?
    14·1 answer
  • Miguel owns a tile business. He has two employees who work in a small office. One answers phones and schedules appointments. Ano
    11·2 answers
  • Helppppppppppppppppppppppppppppppppp
    13·2 answers
  • When trying to upload assignment on canvas wont let me click choose file.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!