Programming and Problem Solving with Java

(やまだぃちぅ) #1

710


d. 0
e. 3
f. 8
g. 3


  1. a.a = 5b = 2
    b.Sum:52
    c. Sum: 52
    d.2 feet


7.


  1. a. 26
    b.reparation
    c. 0
    d. 15
    e. 15
    f. 15


Chapter 3 Programming Warm-Up Exercises
2.intsum;
sum = n*(n+ 1 )/ 2 ;


  1. a.Math.abs(i)
    b.Math.abs(n)
    c. Math.abs(x + y)
    d.Math.abs(x) + Math.abs(y)
    e.Math.pow(x, 3.0)/(x + y)
    f. Math.sqrt(Math.pow(x, 6.0) + Math.pow(y, 5.0))
    g.Math.pow((x + Math.sqrt(y)), 7.0)
    7.This is a laboratory exercise for the student, but it requires that appropriate docu-
    mentation be added.
    // Programming Assignment 2
    // William T. Verts
    // June 27, 2003
    // This application computes the cost per ounce given a total
    // cost and a weight expressed in pounds and ounces.


public classWarmUp2
{
public static voidmain(String[] args)
{
final intTOT_COST = 1376 ; // Total cost

ybb ac=−+−^24

T


E


A


M


F


L


Y


Team-Fly®

Free download pdf