Cash-back offer from May 7th to 12th, 2024: Get a flat 10% cash-back credited to your account for a minimum transaction of $50.Post Your Questions Today!

Question DetailsNormal
$ 18.00

Programming Assignment Week 7 | Complete Solution

Question posted by
Online Tutor Profile
request

Programming Assignment
Grading Information: This Program is due on Sunday of Week 7.
Comments are REQUIRED; flow charts and Pseudocode are NOT REQUIRED.
Directions


Points
The files must be called <LastNameFirstNameProg7.java>. (driver) Fraction.java (handles the fractional numbers)
Example: LastFirstNameProg7.java Fraction.java
Ensure you include ALL files required to make your program compile and run. I would like to see your .java files only.
Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter.

Basic Requirements
Write a driver and fraction class that performs addition, multiplication, prints the fraction, and prints as a double.
LastNameFirstNameProg7.java
Provide a driver class, LastNameFirstNameProg7, that demonstrates this Fraction class. The driver class should contain this main method:
public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); Fraction c, d, x; // Fraction objects
System.out.println("Enter numerator; then denominator."); c = new Fraction(stdIn.nextInt(), stdIn.nextInt()); c.print();
System.out.println("Enter numerator; then denominator."); d = new Fraction(stdIn.nextInt(), stdIn.nextInt());
16
d.print();
x = new Fraction(); // create a fraction for number 0
System.out.println("Sum:"); x.add(c).add(d); x.print(); x.printAsDouble();
x = new Fraction(1, 1); // create a fraction for number 1
System.out.println("Product:"); x.multiply(c).multiply(d); x.print(); x.printAsDouble();
System.out.println("Enter numerator; then denominator.");
x = new Fraction(stdIn.nextInt(), stdIn.nextInt()); x.printAsDouble(); } // end main
Note that this demonstration driver does not call the accessor methods. That’s OK. Accessor methods are often implemented regardless of whether there’s an immediate need for them. That’s because they are very useful methods in general and providing them means that future code can use them when the need arises.
Fraction.java
Write a Fraction class called Fraction.java that implements these methods: add ─ This method receives a Fraction parameter and adds the parameter fraction to the calling object fraction. multiply ─ This method receives a Fraction parameter and multiplies the parameter fraction by the calling object fraction. print ─ This method prints the fraction using fraction notation (1/4, 21/14, etc.) printAsDouble ─ This method prints the fraction as a double (0.25, 1.5, etc.)
Separate accessor methods for each instance variable in the Fraction class.
56
Upload your page to the Dropbox.
NOTE: Complete your activity and submit it to the Dropbox in eCollege
4
Total Points
80
Sample Output
Enter numerator; then denominator. 5 8 5/8
Enter numerator; then denominator. 4 10 4/10 Sum: 82/80 1.025 Product: 20/80 0.25
Enter numerator; then denominator. 6 0 infinity

Available Answer
$ 18.00

[Solved] Programming Assignment Week 7 | Complete Solution

  • This solution is not purchased yet.
  • Submitted On 03 Oct, 2015 04:35:35
Answer posted by
Online Tutor Profile
solution
/** * Fraction Class */ public class Fraction { int numerator; int denominator;...
Buy now to view the complete solution
Other Similar Questions
User Profile
4.0St...

CSIS 312 LU Programming Assignments 1, 2, 3, 4, 5, 6, 7, 8

All Solutions for entire class Included in one order. Programming Assignments 1-8 CSIS312 (BMIS 312) LU ...
User Profile
Exper...

MAT540 Week 8 Assignment 1. Linear Programming Case Study | Complete Solution

Let’s assume they need to order, X1 units of the adult Open Trail, X2 units of the adult Cityscape, X3 units of the girl's Sea Sprite and X4 units of the boy's Trail Blazer to maximize the profit. Then from the given in...
User Profile
smart...

CSCI 114 Programming Fundamentals II | Lab 4 Wallet | Solution

This Tutorial is rated A+ previously,if you have any questions regarding this tutorial then you can contact me....
User Profile
termp...

Object-oriented Programming (OOP) / Event-Driven Programming (EDP) versus Procedural Programming

Object-oriented Programming (OOP)Object-oriented Programming (OOP)Object-oriented Programming (OOP) ...
User Profile
termp...

IT244M2Part1A.docx Security with Python Programming Purdue University Global Python S

IT244M2Part1A.docx Security with Python Programming Purdue University Global Python Security The python coding language is a great tool for data security. Since python is open source there are a wide variety of librarie...

The benefits of buying study notes from CourseMerits

homeworkhelptime
Assurance Of Timely Delivery
We value your patience, and to ensure you always receive your homework help within the promised time, our dedicated team of tutors begins their work as soon as the request arrives.
tutoring
Best Price In The Market
All the services that are available on our page cost only a nominal amount of money. In fact, the prices are lower than the industry standards. You can always expect value for money from us.
tutorsupport
Uninterrupted 24/7 Support
Our customer support wing remains online 24x7 to provide you seamless assistance. Also, when you post a query or a request here, you can expect an immediate response from our side.
closebutton

$ 629.35