Introduction to java programming comprehensive version 10th edition liang solutions manual 1

Page 1

Introduction to Java Programming

Comprehensive Version 10th Edition

Liang Solutions Manual

Full download at link:

Solution Manual: https://testbankpack.com/p/solution-manualfor-introduction-to-java-programming-comprehensiveversion-10th-edition-liang-0133761312-9780133761313/

Test Bank: https://testbankpack.com/p/test-bank-forintroduction-to-java-programming-comprehensive-version10th-edition-liang-0133761312-9780133761313/

Student Name: __________________

Class and Section __________________

Total Points (20 pts)

Due: September 20, Monday, 2012 before the class

Project: Proper Fractions, Improper Fractions, and Mixed Fractions

CSCI 1301 Introduction to Programming Principles

Armstrong Atlantic State University

Problem Description:

Proper fractions, improper fractions, and mixed fractions are defined at http://www.ltcconline.net/greenl/courses/187/b/impro permixed.htm. Write a program that prompts the user to enter the numerator and denominator of a fraction number and determines whether it is a proper fraction and improper fraction. For an improper fraction number, display its mixed fraction in the form of a + b / c if b % c is not zero; otherwise, display only the integer.

1

Here are sample runs of the program:

Sample 1: Enter a numerator: 16

Enter a denominator: 3 16 / 3 is an improper fraction and its mixed fraction is 5 + 1 / 3.

Sample 2: Enter a numerator: 6 Enter a denominator: 7 6 / 7 is a proper fraction

Sample 3: Enter a numerator: 6 Enter a denominator: 2 6 / 2 is an improper fraction and it can be reduced to 3

Analysis:

(Describe the problem including input and output in your own words.)

Design:

(Describe the major steps for solving the problem.)

Coding: (Copy and Paste Source Code here. Format your code using Courier 10pts)

Name the program Exercise03_01Extra

2

Testing: (Describe how you test this program)

Submit the following items:

1. Print this Word file and Submit to me before the class on the due day

2. Compile, Run, and Submit to LiveLab (you must submit the program regardless whether it complete or incomplete, correct or incorrect)

3

Code Solution:

import java.util.Scanner;

public class Exercise03_01Extra { public static void main(String args[]) { Scanner input = new Scanner(System.in);

System.out.print("Enter a numerator: "); int numerator = input.nextInt();

System.out.print("Enter a denominator: "); int denominator = input.nextInt();

if (numerator < denominator) { System.out.println(numerator + " / " + denominator + " is a proper fraction");

}

else if (numerator % denominator == 0) { System.out.print(numerator + " / " + denominator + " is an improper fraction ");

System.out.println("and it can be reduced to " + numerator / denominator);

}

else {

System.out.print(numerator + " / " + denominator + " is an improper fraction ");

System.out.println("and its mixed fraction is " + numerator / denominator + " + " + numerator % denominator + " / " + denominator);

4
} } }

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.
Introduction to java programming comprehensive version 10th edition liang solutions manual 1 by mark.tedesco515 - Issuu