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

Frac Add

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 Fracadd{ //REMEMBER: Your program will not run if you do not use this exact class!
public static void main(String args[])
{
int FNum = 2;// changing these numbers chages the fractions.
int FDen = 3;
int SNum = 1;
int SDen = 4;

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); //This line does the math //to figure out what they will add to
}
}

 

New Terms!

int: The integer type hold 32-bits of data and is always an integer (Surprise, Surprise!).