Site hosted by Angelfire.com: Build your free website today!

Frac Add Parse

If you wish to view the code only, check this page. You can click the links and it should open up in a notepad file.

 

class FracAddParse{
public static void main(String args[])
{ //args means arguments

int FNum = Integer.parseInt(args[0]);
int FDen = Integer.parseInt(args[1]);
int SNum = Integer.parseInt(args[2]);
int SDen = Integer.parseInt(args[3]);

System.out.println("Hello World! We're adding fractions!");

// Notice that words in quotes are printed out, variables are not in quotes.

System.out.println(FNum +"/"+ FDen + "plus " + SNum + "/" +SDen);
System.out.println("adds to:");
System.out.println(FNum*SDen + SNum*FDen +" / "+ FDen*SDen);
}
}

 

New Terms!

 Integer.parseInt: Adds an argument to the program, and reads what the user types.