SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,kenrick Mock
Chapter:
Getting Started
Exercise:
Programming Projects
Question:6 | ISBN:9780132830317 | Edition: 5

Question

Bicyclists can calculate their speed if the gear size and cadence is known. Gear size refers to the effective diameter of the wheel. Gear size multiplied by pi (3.14) gives the distance travelled with one turn of the pedals. Cadence refers to the number of pedal revolutions per minute (rpm). The speed in miles per hour is calculated by the following:



This is a program that calculates the speed for a gear size of 100 inches and a cadence of 90 rpm. This would be considered a high cadence and a maximum gear size for a typical bicycle. In writing your program, don’t forget that the expression 1/12 will result in 0, because both 1 and 12 are integers, and when the integer division is performed, the fractional part is discarded.


TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

Program:

// BicyclistSpeed
public class BicyclistSpeed
{
	public static double PI = 3.14;

	public static void main(String[] args)
	{
		double gearSizeInInches = 100.0;
		double cadenceInRPM = 90.0;

		double speedInMPH = gearSizeInInches * PI * (1.0 / 12.0)
				             * (1.0 / 5280.0) * cadenceInRPM * (60.0 / 1.0);

		System.out.println("Gear size in inches   : " + gearSizeInInches);
		System.out.println("Cadence in RPM        : " + cadenceInRPM);
		System.out.println("Bicyclist speed in MPH: " + speedInMPH);
	}
}

Output:

Gear size in inches   : 100.0
Cadence in RPM        : 90.0
Bicyclist speed in MPH: 26.761363636363633

 

0 0

Discussions

sinaaa

answer of question 6 in 6th edition of this book!

import java.util.Scanner;
import java.lang.Math;

public class Review1 {
    
    public static void main(String[] args) {
        Scanner keyboard = new Scanner(System.in);
        
        System.out.println("Enter your principal amount of yout money: ");
        double p = keyboard.nextDouble();
        System.out.println("Enter the initial interest rate in decimal form: ");
        double r = keyboard.nextDouble();
        System.out.println("Enter the number of years: ");
        int t = keyboard.nextInt();
        System.out.println("Enter the number of times interest is compounded per unit 't': ");
        
        /* If interest is compounded yearly,then n = 1;
         * if semi-annually, then n = 2;
         * quarterly, then n = 4; monthly, then n = 12;
         * weekly, then n = 52; daily, then n = 365; 
         * and so forth, regardless of the number of years involved.
         */
        
        int n = keyboard.nextInt();
        
        double simpleInterst = (p*r*t);
        
        double compoundInterest = (p*(Math.pow((1+r/n), n*t))) - p;
        
        System.out.println("the simple interest is: " + simpleInterst + "\n");
        System.out.println("the compund interest is: " + compoundInterest);
        
        keyboard.close();
        


    }


}

Post the discussion to improve the above solution.