bartleby

Concept explainers

bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 6.3, Problem 28STQ

Explanation of Solution

Program:

Changes in definition of the method "writePositive()" in "DollarFormat" class:

File name: DollarFormat.java:

//Define the class

public class DollarFormat

{

/*Refers the textbook of Listing 6.14*/

//Define the method "writePositive()"

private static void writePositive(double amount)

{

//Assign the value to the variable "allCents"

long allCents = Math.round(amount * 100);

//Assign the value to the variable "dollars"

long dollars = allCents / 100;

//Assign the value to the variable "cents"

long cents = allCents % 100;

//Print the dollars

System.out.print(dollars);

//Print the dot

System.out.print('.');

//Check the condition

if (cents < 10)

//True, print the cents

System.out.print('0');

System.out.print(cents);

}

//Define the method "writeln()"

public static void writeln(double amount)

{

//Call the method "write()"

write(amount);

//Print the new line

System.out.println( );

}

}

File name: DollarFormatDriver.java:

//Import necessary header files

import java.util.Scanner;

//Define the class

public class DollarFormatDriver

{

//Define the "main()" method

public static void main(String[] args)

{

//Declare the necessary variables

double amount;

String ans;

//Create object for "Scanner()"

Scanner keyboard = new Scanner(System...

Blurred answer
Students have asked these similar questions
Python - Need help! How do I have an input in turtle to display my name below the circle it draws and another input to display my age written below that? Code: import turtlebackground = "#FFFFFF" def draw_circle(radius, line_color, fill_color): my_turtle.color(line_color) my_turtle.fillcolor(fill_color) my_turtle.begin_fill() my_turtle.circle(radius) my_turtle.end_fill() def move_turtle(x, y): my_turtle.penup() my_turtle.goto(x, y) my_turtle.pendown() turtle.done()
Need help fixing my python code! Images attached on the required modficications I dont know how to do. Simpler the better.Code: (in images)
Answer all of the questions with steps by step explanation to every question.

Chapter 6 Solutions

Java: An Introduction to Problem Solving and Programming (8th Edition)

Chapter 6.2, Problem 11STQ Chapter 6.2, Problem 12STQ Chapter 6.2, Problem 13STQ Chapter 6.2, Problem 14STQ Chapter 6.2, Problem 15STQ Chapter 6.2, Problem 16STQ Chapter 6.2, Problem 17STQ Chapter 6.2, Problem 18STQ Chapter 6.2, Problem 19STQ Chapter 6.2, Problem 20STQ Chapter 6.2, Problem 21STQ Chapter 6.2, Problem 22STQ Chapter 6.2, Problem 23STQ Chapter 6.2, Problem 24STQ Chapter 6.2, Problem 25STQ Chapter 6.2, Problem 26STQ Chapter 6.3, Problem 27STQ Chapter 6.3, Problem 28STQ Chapter 6.3, Problem 29STQ Chapter 6.3, Problem 30STQ Chapter 6.3, Problem 31STQ Chapter 6.4, Problem 32STQ Chapter 6.4, Problem 33STQ Chapter 6.4, Problem 34STQ Chapter 6.4, Problem 35STQ Chapter 6.4, Problem 36STQ Chapter 6.4, Problem 37STQ Chapter 6.4, Problem 38STQ Chapter 6.4, Problem 39STQ Chapter 6.5, Problem 40STQ Chapter 6.6, Problem 41STQ Chapter 6.7, Problem 42STQ Chapter 6.7, Problem 43STQ Chapter 6.7, Problem 44STQ Chapter 6.7, Problem 45STQ Chapter 6.8, Problem 46STQ Chapter 6, Problem 1E Chapter 6, Problem 2E Chapter 6, Problem 3E Chapter 6, Problem 4E Chapter 6, Problem 5E Chapter 6, Problem 6E Chapter 6, Problem 7E Chapter 6, Problem 8E Chapter 6, Problem 9E Chapter 6, Problem 10E Chapter 6, Problem 11E Chapter 6, Problem 12E Chapter 6, Problem 1P Chapter 6, Problem 2P Chapter 6, Problem 3P Chapter 6, Problem 4P Chapter 6, Problem 5P Chapter 6, Problem 6P Chapter 6, Problem 7P Chapter 6, Problem 1PP Chapter 6, Problem 2PP Chapter 6, Problem 3PP Chapter 6, Problem 4PP Chapter 6, Problem 5PP Chapter 6, Problem 6PP Chapter 6, Problem 7PP Chapter 6, Problem 8PP Chapter 6, Problem 9PP Chapter 6, Problem 10PP Chapter 6, Problem 11PP Chapter 6, Problem 12PP

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Main.java Include the required "import" statement. Define the main class. Define the main method using "public ...

Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)

The tolerance between hole centers.

Degarmo's Materials And Processes In Manufacturing

Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
    Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781305480537
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    Programming Logic & Design Comprehensive
    Computer Science
    ISBN:9781337669405
    Author:FARRELL
    Publisher:Cengage
    Text book image
    C++ Programming: From Problem Analysis to Program...
    Computer Science
    ISBN:9781337102087
    Author:D. S. Malik
    Publisher:Cengage Learning
    Text book image
    Operations Research : Applications and Algorithms
    Computer Science
    ISBN:9780534380588
    Author:Wayne L. Winston
    Publisher:Brooks Cole
    Java Math Library; Author: Alex Lee;https://www.youtube.com/watch?v=ufegX5o8uc4; License: Standard YouTube License, CC-BY