answer.
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
stich3
2 months 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:
Natasha_Volkova [1K]2 months ago
6 0

Answer:

Substitute /* Type your code here. */ with these lines:

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 respective coin counts as integers:

int quarter =scnr.nextInt();

int dime = scnr.nextInt();

int nickel = scnr.nextInt();

int penny = scnr.nextInt();

This line computes the total amount in dollars:

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

Lastly, the subsequent two lines output the dollar and cents value respectively:

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

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

You might be interested in
Suppose we are sorting an array of eight integers using quicksort, and we have just finished the first partitioning with the arr
Rzqust [1037]

Answer:

c. The pivot could either be 7 or 9.

Explanation:

When sorting an array of eight integers through quicksort, the first partitioning indicates that either 7 or 9 may serve as the pivot. Observing the array, it is specifically 7 and 9 that occupy their correct positions within the ordered array. All integers preceding 7 and 9 are lesser, and all numbers following them are greater. Therefore, it suggests that the pivot is located between 7 and 9.

6 0
1 month ago
Choose the person responsible for each innovation.
zubka84 [1067]

Response:

John Blankenbaker

Reasoning:

5 0
1 month ago
List at least six things you would check for if you were asked to evaluate the workspace of an employee for ergonomics
maria [1035]

Evaluating the risks related to employees remaining stationary for extended periods at their workstations is critical. Below is a compilation of key ergonomic principles that aid in identifying ergonomic risk factors.


<span>1.    </span>Are employees kept in a neutral posture?

<span>2.    </span>Does the workstation provide opportunities for movement and stretching?

<span>3.    </span>Is the lighting sufficient?

<span>4.    </span>Are the chairs adjustable as needed?

<span>5.    </span>Are suitable footrests available?

<span>6.    </span>Is there additional storage to enhance desk organization?






0 0
2 months ago
Write a loop that prints each country's population in country_pop. Sample output for the given program.
zubka84 [1067]

Response:

Correct script pertaining to the previous query that showcases the output.

for x, y in country_pop.items(): #this for loop iterates through the list items.

   print(str(x) + " has " + str(y) + " people") #output function to display the values.

Result:

  • This code is written in Python and produces the output required by the previous question.

Clarification:

  • The code in the previous question is intended for Python language to show the output, however, it has inaccuracies.
  • A 'for' loop is necessary, which will allow the items to be displayed one at a time.
  • The list presented is structured as key-value pairs, thus the use of the 'items' function from Python dictionaries is essential to present the list items.
  • Additionally, two variables must be established in the for loop, one representing the key and the other representing the value.
7 0
1 month ago
Given positive integer numInsects, write a while loop that prints that number doubled without reaching 200. Follow each number w
zubka84 [1067]

Answer:

The code placed where "/*Your solution goes here */" is as follows:

while(numInsects<200) // while loop

       {

            System.out.print(numInsects+" "); // output statement

            numInsects=numInsects*2; // operation to double the value.

       }

Output:

  • If the input is 16, the result is 16 32 64 128.
  • If the input is 25, the result is 25 50 100.

Explanation:

  • The above Java code fills the section designated as "Your solution" and will operate correctly.
  • The program accepts a user input and continues to print double the value until it reaches 200 or more.
  • The while loop evaluates whether the value remains below 200. If so, the operation proceeds; otherwise, it stops.
5 0
1 month ago
Other questions:
  • Why were the practitioners of alternative software development methods not satisfied with the traditional waterfall method?
    9·1 answer
  • Accenture is helping a large retailer transform their online sales and services. The Data Analyst audits the client’s customer j
    12·1 answer
  • . Electricians will sometimes call ______ "disconnects" or a "disconnecting means."
    12·1 answer
  • Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 3 8 the output is
    5·1 answer
  • What is the other name designated to a game master of multiplayer online games (MMOs)?
    11·2 answers
  • If a database named Contacts has a table named tblEmployees and another database named Orders links to that tblEmployees table,
    8·1 answer
  • Tanya wants to include a video with all its controls on her web page. The dimensions of the video are as follows:
    6·2 answers
  • Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the person's age. Complete fat_burn
    10·1 answer
  • Consider two different implementations, M1 and M2, of the same instruction set. There are three classes of instructions (A, B, a
    14·1 answer
  • #Write a function called random_marks. random_marks should #take three parameters, all integers. It should return a #string. # #
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!