# modify Fraction program

modify the FractionalMath programe so it performes a partial input valdiation . If either fraction does not contian exactly one slash , have the program prompt the user to re-enter the fraction . The program will repeat the prompt as often as necessary until the user enters a string containing one slash.

## Deliverables

enter first fraction: 3/5 enter second fraction: 1/6 sum: 23/30 Difference :13/30 Product:3/30 Quotient 18/15 ALL OPERATIONS ARE THE CALLING OBJECT op F *****/ import java.io.*; public class Fraction { private int num, den; //Two constructor public Fraction(int n, int d) { num = n; //Numerator den = d; //Denominator if(den < 0) { num *= -1; den *= -1; } } //another constructor //pass the fraction in the string like "1/2" public Fraction(String f) { int i = 0; boolean done = false; while(!done) { if([url removed, login to view](i) == '/') done = true; else i++; } String n = [url removed, login to view](0, i); String d = [url removed, login to view](i+1, [url removed, login to view]()); Integer i1 = new Integer(n); num = [url removed, login to view](); Integer i2 = new Integer(d); den = [url removed, login to view](); if(den == 0) { den *= -1; num *= -1; } } //default constructor public Fraction() { num = 0; den = 1; } //////////////////// //ALL OPERATIONS ARE THE CALLING OBJECT op F // Fraction f; // [url removed, login to view](f2); is f - f2 /////////////////// public Fraction add(Fraction f) //Add method { Fraction sum = new Fraction(); [url removed, login to view] = den * [url removed, login to view]; [url removed, login to view] = num * [url removed, login to view] + [url removed, login to view] * den; return sum; } public Fraction sub(Fraction f) //Subtract method { Fraction dif = new Fraction(); [url removed, login to view] = den * [url removed, login to view]; [url removed, login to view] = num * [url removed, login to view] - [url removed, login to view] * den; return dif; } public Fraction mul(Fraction f) //Multiply Method { Fraction prod = new Fraction(); [url removed, login to view] = den * [url removed, login to view]; [url removed, login to view] = num * [url removed, login to view]; return prod; } public Fraction div(Fraction f) //Divide method { Fraction quot = new Fraction(); [url removed, login to view] = den * [url removed, login to view]; [url removed, login to view] = num * [url removed, login to view]; return quot; } public void display() { [url removed, login to view](num); [url removed, login to view]('/'); [url removed, login to view](den); [url removed, login to view](" "); } public static void main(String[] args) { Fraction f1, f2; BufferedReader in = new BufferedReader(new InputStreamReader([url removed, login to view])); try { Fraction f3 = new Fraction(); [url removed, login to view]("Enter first fraction: "); //First Prompts for the Input X/Y String tmpstr_f1 = [url removed, login to view](); f1 = new Fraction(tmpstr_f1); [url removed, login to view]("Enter second fraction: "); //Second Prompt X/Y String tmpstr_f2 = [url removed, login to view](); f2 = new Fraction(tmpstr_f2); f3 = [url removed, login to view](f2); [url removed, login to view]("Sum :"); //Output of Sum [url removed, login to view](); f3 = [url removed, login to view](f2); [url removed, login to view]("\nDifference :"); //Output of Difference [url removed, login to view](); f3 = [url removed, login to view](f2); [url removed, login to view]("\nProduct :"); //Output of Products [url removed, login to view](); f3 = [url removed, login to view](f2); [url removed, login to view]("\nQuotent :"); //Output of Quotient [url removed, login to view](); } catch(IOException e) { [url removed, login to view]("error"); } } }

## Platform

window melenium

Habilidades: Engenharia, Java, MySQL, PHP, Arquitetura de software, Teste de Software

Acerca do Empregador:
( 73 comentários ) United States

ID do Projeto: #2839484

## Concedido a:

katstanaka

See private message.

\$5 USD em 14 dias
(26 Comentários)
3.7

## 8 freelancers estão ofertando em média \$11 para esse trabalho

cinterosystems

See private message.

\$10.2 USD in 14 dias
(139 Comentários)
5.6
smartpin

See private message.

\$11.05 USD in 14 dias
(60 Comentários)
5.0
avichapman

See private message.

\$14.45 USD in 14 dias
(28 Comentários)
4.5
asadsufi

See private message.

\$8.5 USD in 14 dias
(38 Comentários)
4.1
sirjavacodesalot

See private message.

\$17 USD in 14 dias
(9 Comentários)
3.3
odysseyvw

See private message.

\$8.5 USD in 14 dias
(32 Comentários)
3.3
dannynoest

See private message.

\$12.75 USD in 14 dias
(15 Comentários)
2.7