Absolute Java (6th Edition)
Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Videos

Textbook Question
Chapter 1, Problem 8PP

The following program will compile and run, but it uses poor programming style. Modify the program so that it uses the spelling conventions, constant naming conventions, and formatting style recommended in this book.

public class vehicleAvgSpeed { public static void main{String[] args) { double TIME; System .out .println("This program calculates vehicle average speed given a time and distance traveled ."); TIME = 20 .5; AVERAGE_SPEED = distance / TIME; System .out .println("Car average speed is " + AVERAGE_SPEED + " miles per hour ."); } public static final double distance = 180; }

Blurred answer
Students have asked these similar questions
IN JAVA   The following program generates an error. Why?   public static void printSum(int num1, int num2) {System.out.print(num1 + num2);}public static void main(String args[]) {int y;y = printSum(4, 5); return 0;}   A. printSum() is missing a "return;" statement. B. The values 4 and 5 cannot be passed directly to printSum() C. main() has a return statement that returns the value 0 D. printSum() has void return type, so cannot be assigned to a variable
In JAVA ASSIGNMENT DESCRIPTION: A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-life of about 6 hours in humans. Given caffeine amount (in mg) as input, output the caffeine level after 6, 12, and 24 hours. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:System.out.printf("After 6 hours: %.2f mg\n", yourValue); Ex: If the input is: 100 the output is: After 6 hours: 50.00 mg After 12 hours: 25.00 mg After 24 hours: 6.25 mg Note: A cup of coffee has about 100 mg. A soda has about 40 mg. An "energy" drink (a misnomer) has between 100 mg and 200 mg. THE CODE I HAVE SO FAR: import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); double caffeineMg; // "double" supports floating-point like 75.5, versus int for integers like 75.   caffeineMg = scnr.nextDouble(); System.out.printf("After…
Please help me with the below  please post the program below into the bigger program. And please ensure that the big program works  class Main {   static int fT = 2, ST = 2, CT = 0;  static int fN=3,sN=3,cN=0;       static void number(int num) {       if (num < 17) {       return;     } else {         System.out.print(num + " ");       // call function recursively       number(num - 1);     }   }     static void number1(int num) {       if (num < 9) {       return;     } else {       System.out.print(num + " ");       // call function recursively       number1(num - 2);     }     }     static void number3(int num) {       if (num > 18) {       return;     } else {       System.out.print(num + " ");       // call function recursively       number3(num + 2);     }   }     static void number4(int num) {     if (num > 10) {       return;     } else {       System.out.print(num + " "); // call function recursively       number4(num + 1);     }   }     static void number5(int…

Chapter 1 Solutions

Absolute Java (6th Edition)

Ch. 1 - Can a Java program have two different variables...Ch. 1 - Give the declaration for two variables called feet...Ch. 1 - Give the declaration for two variables called...Ch. 1 - Prob. 14STECh. 1 - Prob. 15STECh. 1 - Prob. 16STECh. 1 - Convert each of the following mathematical...Ch. 1 - What is the output of the following program...Ch. 1 - What is the output produced by the following lines...Ch. 1 - Prob. 20STECh. 1 - Given the following fragment that purports to...Ch. 1 - What is the output produced by the following lines...Ch. 1 - What is the output produced by the following lines...Ch. 1 - What is the output produced by the following? Ch. 1 - What is the output produced by the following?...Ch. 1 - What is the output produced by the following?...Ch. 1 - What is the output produced by the following? Ch. 1 - Prob. 28STECh. 1 - Prob. 29STECh. 1 - What is the output of the following two lines of...Ch. 1 - Suppose sam is an object of a class named Person...Ch. 1 - The following code is supposed to output the...Ch. 1 - Prob. 33STECh. 1 - What is the output produced by the following Java...Ch. 1 - What is the normal spelling convention for named...Ch. 1 - Write a line of Java code that will give the name...Ch. 1 - Body Mass Index (BMI) helps in specifying the...Ch. 1 - The video game machines at your local arcade...Ch. 1 - Write a program that starts with the string...Ch. 1 - A government research lab has concluded that an...Ch. 1 - Write a program that starts with a line of text...Ch. 1 - Write a program for calculating the simple...Ch. 1 - Write a program that outputs the number of hours,...Ch. 1 - The following program will compile and run, but it...Ch. 1 - A simple rule to estimate your ideal body weight...Ch. 1 - Scientists estimate that roughly 10 grams of...

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Computer Science
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
  • Below is a java program to find roots of quadratic equation. Please explain each line of code if what it does in the program when executed. Example: Java Program to Find Roots of a Quadratic Equation public class Main {   public static void main(String[] args) { double a = 2.3, b = 4, c = 5.6; double root1, root2; double determinant = b * b - 4 * a * c;   if (determinant > 0) { root1 = (-b + Math.sqrt(determinant)) / (2 * a); root2 = (-b - Math.sqrt(determinant)) / (2 * a); out.format("root1 = %.2f and root2 = %.2f", root1, root2); } else if (determinant == 0) { root1 = root2 = -b / (2 * a); out.format("root1 = root2 = %.2f;", root1); } else { double real = -b / (2 * a); double imaginary = Math.sqrt(-determinant) / (2 * a); out.format("root1 = %.2f+%.2fi", real, imaginary); out.format("\nroot2 = %.2f-%.2fi", real, imaginary); } } }
    In Java only please. The following progam uses a series to find the approximate value of pi. However, the statements are in the wrong order and there is also a bug in this program. Rearrange the statements and also fine and remove the bug so that this program can be used to approximate pi   import java.util.*; public class Ch5_PrExercise2 { static Scanner console = new Scanner(System.in); public static void main(String[] args) { double pi = 0; long i ; long n;   n = console.nextOnt(); System.out.print("Enter the value of n:  "); System.out.println(); if(i % 2 == 0) pi = pi + (1 / (2 * i + 1)); else pi = pi - (1 / (2 * i + 1)); for(i = 0; i < n; i++) { pi = 0; pi = 4 * pi; } System.out.println("pi = " + [i); ) Note I know  that the code go in the following order but not sure about the order of the if-else statement.   n =System.out.print("Enter the value of n:  "); console.nextInt(); System.out.println(); for(i = 0; i < n; i++) { pi = 0; pi = 4 * pi;   for(i = 0; i < n; i++) {…
    Question: (Code must be in java language) Assuming that you have the functions “drawPolygon(int[] x, int[] y, int n)” for drawing polygon, “drawRectangle(int x, int y, int width, int height)” for drawing rectangle and “drawCircle(int xc, intyc, int radius)” for drawing circle; draw the given shape. Where: R(300,250), T1(325,275), T2(475,275), T3(400,400), P1(285,250), P2(225,275), P3(200,450), P4(285, 300), Q1(515,250), Q2(575,275), Q3(600,450), Q4(515,300)//Look attached image here Note: No need to write the definition of the methods, there are no marks for definition. Only use method calls to create the shape as shown in Figure 1.
  • Write java program that will calculate the amount to be paid for electrical consumption.  This problem is to handle electric billing for customers. The billing is depending on the type of the customer account. There are two types of customers account; i) fixed rate method and 2) variable rate method in the case of fixed rate method. The minimum monthly charge of RM20.00 is assessed if the consumption is less than or equal 100 kwh( kilowatt-hours). Otherwise, the rate of RM 0.22 per kWh is charged for the first 100 kWh and the rate of RM 0.33 per kWh is charged for the additional consumption. In the case of variable rate method, the rate of RM 0.22 per kWh is charged for the consumption less than or equal to 100 kWh. Any additional consumption is charged at RM 0.35 per kWh.
    1  public static int sum(int x, int y){   2     int z = x +y;   3     return z;   4 }      5 public static void main(String[] args){    6    …    7      sum(a+2, b);    8  …    9 }      write the signature of the method sum: sum(int,int) *Method name/parameter list   list local variables of sum: x, y, and y are local variables of the function.    list the parameters of sum: int x, int y   write the line number where a call to sum occurs 7    list the arguments for the above call   list the return type of sum here ______________
    PROBLEM STATEMENT: Return the factorial of the provided integer parameter. public class FactorialComputation{public static int solution(int n){// ↓↓↓↓ your code goes here ↓↓↓↓return 0;}   Can you please help me with the question above  the Language is Java and can yiu use the java code that i gave above to answer the question
  • In Java please.Enter the code where it says " /* Your code goes here */ ". Suppose we add a fixed amount of money into our bank account at the beginning of every year. Modify the program from this section to show how many years it takes for the balance to double, given the annual contributions and the interest.   import java.util.Scanner;/**   This program computes the time required to double an investment   with an annual contribution.*/public class DoubleInvestment{   public static void main(String[] args)   {      final double RATE = 5;      final double INITIAL_BALANCE = 10000;      final double TARGET = 2 * INITIAL_BALANCE;       Scanner in = new Scanner(System.in);      System.out.print("Annual contribution: ");      double contribution = in.nextDouble();       double balance = INITIAL_BALANCE;      int year = 0;       // TODO: Add annual contribution, but not in year 0       /* Your code goes here */       System.out.println("Year: " + year);      System.out.printf("Balance:…
    Use the class provided, TestOverloadCall printMax to print the highest of 33 and 89Call printMax to print the highest of 55, 11, 99Submit, a print screen of the code and the output   public class TestOverload {public static void main(String[] args) {//Call printMax to print the highest of 33 and 89//Call printMax to print the highest of 55, 11, 99}public static void printMax (int num1, int num2){if (num1 > num2)System.out.println("The highest is " + num1);elseSystem.out.println("The highest is " + num2);}//End of printMaxpublic static void printMax (int num1, int num2, int num3){if (num1 > num2 && num1 > num3)System.out.println("The highest is " + num1);else if (num2 > num1 && num2 > num3 )System.out.println("The highest is " + num2);elseSystem.out.println("The highest is " + num3);}//End of printMax}//End of TestOverload
    Fix the mistakes in the following program so it runs as expected. There are 5 mistakes. All literals (such as 3.5) have the correct value and data type.  // Java program by [Student name] [Today's date] public class Mistakes {        public static void main(String[] args) {               / This is a comment               int z = 3.5;                System.out.println("z is + z");                 int s2 = "Michael";               System.out.println("s2 has the value " s2);        } } Please show the mistakes clearly and how the change is made.
  • The body mass index, BMI, is a measure used to determine if a person is overweight or not. We can calculate BMI from the weight of the person (in pounds) and the height (in inches) of the person.The formula for calculating BMI is:BMI = (weightInPounds * 703) divided by (heightInInches squared)In this problem, you will develop a Java program as a BMI calculator, that reads the user’s weight in pounds and height in inches, then calculates and displays the user’s body mass index BMI. Also, display the following information {from the US Department of Health} so the user can evaluate his/her BMI:BMI values:Underweight: less than 18.5Normal: between 18.5 and 24.9Overweight: between 25 and 29.9Obese: 30 or greater
    I keep coming up with the wrong answer, please help: Here is the code given: public class Billing {final static double TAX = 0.08;public static void main(String[] args) {final double HIGHPRICE = 24.99;final double MEDPRICE = 17.50;final double LOPRICE = 10.00;final int QUAN1 = 4;final int QUAN2 = 6;double bill;bill = computeBill(HIGHPRICE);System.out.println("The total for a photobook that costs $" +HIGHPRICE + " is $" + bill);bill = computeBill(MEDPRICE, QUAN1);System.out.println("The total for " + QUAN1 +" photobooks that cost $" +MEDPRICE + " is $" + bill);bill = computeBill(LOPRICE, QUAN2, 20.00);System.out.println("The total for " + QUAN2 +" photobooks that cost $" +LOPRICE + " with a $20 coupon is $" + bill);} public static double computeBill(double amt) {// Write your code here} public static double computeBill(double amt, int quantity) {// Write your code here}public static double computeBill(double amt, int quantity, double coupon) {// Write your code here}} Here is what they…
    **JAVA DEBUGGING** The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. public classDebugSeven3 {    public static void main(String[] args)    {        String quote =          "Honesty is the first chapter in the book of wisdom. - Thomas  Jefferson";       System.out.println("index.of('f') is: " + quoteindexOf('f'));       System.out.println("index.of('x') is: " + quoteindexOf('x'));       System.out.println("char.At(5) is: " + quote.charAt(50));       System.out.println("endsWith(\"daughter\") is: " + quote.endsWith("daughter"));       System.out.println("endsWith(\"son\") is: " + quote.endsWith("son"));       System.out.println("replace('e', '*') is: ", quote.replace('e', '*'));    } }
    • SEE MORE QUESTIONS
    Recommended textbooks for you
  • Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
  • C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education
  • Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education
    Program to find HCF & LCM of two numbers in C | #6 Coding Bytes; Author: FACE Prep;https://www.youtube.com/watch?v=mZA3cdalYN4;License: Standard YouTube License, CC-BY