Question: please help. Program #1: Add divide method to take another Fraction as the parameter and return a new Fraction that is the division of current

 please help. Program #1: Add divide method to take another Fractionas the parameter and return a new Fraction that is the divisionof current Fraction and the Fraction in the parameter. (public Fraction divide(Fractionf)). Add scaleup and scaledown methods to the Fraction class. The scaleup please help.

Program #1: Add divide method to take another Fraction as the parameter and return a new Fraction that is the division of current Fraction and the Fraction in the parameter. (public Fraction divide(Fraction f)). Add scaleup and scaledown methods to the Fraction class. The scaleup method will take a factor as the parameter and multiply the numerator by the factor. The scaledown method will take a factor as the parameter and multiply the denominator by the factor. Add a scale method which will have two parameters: factor and flag. The flag is boolean. If flag is true, then scale up the fraction; otherwise scale down the fraction. Both scaledown and scale methods must check if the factor is 0. If it is 0, a warning message is printed out and no scaling is operated. Add two more constructors. One of the constructors will have no parameters; it| initializes the fraction to 0/1. The other constructor will have one parameter, representing the numerator of the fraction; the denominator of the fraction will be 1. Write a program named Fraction Scale that prompts the user of a fraction and a scale factor. Here is what the user will see on the screen: This program performs the scaling operations on a fraction. Enter a fraction: 3/7 Scale up or down (1: up, O: down): 1 Enter a scale factor 2 Scaled fraction is: 677 You can assume that the user always enters two integers separated by a slash (/) for the faction. However, the user may enter any number of spaces before and after each integer public class Fraction { // Instance variables private int numerator; // Numerator of fraction private int denominator; // Denominator of fraction // Constructors public Fraction(int num, int denom) { numerator = num; denominator = denom; // Instance methods public int getNumerator() { return numerator; public int getDenominator() { return denominator; public Fraction add(Fraction f) { int num = numerator * f.denominator + f.numerator * denominator; int denom = denominator * f.denominator; return new Fraction(num, denom); Program #2: Following is a part of the source codes for NBATeam and NBA classes. Finish the programs for both classes to produce an output screen similar to the following figure. Creat the NBA team of Heats Add a play to Heats? (yeso): yes What is the name to be added? James Add one more play to Heats? (yeso): yes What is the name to be added? Wade Add one more play to Heats? (yeso): no Creat the NBA team of Spurs Add a play to Spurs? (yeso): yes What is the name to be added? Duncan Add one more play to Spurs? (yeso): yes What is the name to be added? Parker Add one more play to Spurs? (yeso): no Game on Now ...... Spurs ***WIN the series*** Heats[ James Wade ) win #: 2 los Spurs [ Duncan Parker ) win #: 4 los : 2 4 I/File NBA.java import java.util.Scanner; l/File NBA.java import java.util.Scanner; public class NBA { public static void main(String[] args) { Scanner input = new Scanner (System.in); String ifAddPlayer; String playerName; Heats ... //construct Team Heat System.out.println("Creat the NBA team of "); NBATeam heat= new NBATeam("Heats"); System.out.print("Add a play to Heats? (yeso): "); ifAddPlayer= input.next(); while (ifAddPlayer.equalsIgnoreCase("yes")){ System.out.print("What is the name to be added? "); playerName=input.next(); heat. addAPlayer(playerName); System.out.print("Add one more play to Heats? (yeso): "); ifAddPlayer= input.next(); // construct Team spurs .../ /Your code here /*simulate a series of atmost 7 games by generating a random number; if the random number is bigger than 0.5, Heat wins; otherwise Heat losses a game. As soon as team wins 4 games, the series is over. * .....//Your code here System.out.println(heat); System.out.println(spurs); ranaom number; it the ranaom number is bigger than 0.), Heat wins; otherwise Heat losses a game. As soon as team wins 4 games, the series is over. */ ....../ /Your code here System.out.println(heat); System.out.println(spurs); l/File NBATeam.java public class NBATeam { private String sTeamName; private int nWin; private int nLoss; private String [] playerArray; //Your code here }//end of class definition

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!