nigana @ Mon May 11, 2009 12:04 pm wrote:
can someone help me with this questions, i am really confused.
5.Write a program that inputs two fractions in the form a/b and c/d, and outputs their sum in the form p / q cancelled down to its simplest form. This should continue until the user types in an exit command of your choice.
Sample run: Input: 5/6 1/10
Output: 14/15
var num1,dem1,num2,dem2:int
loop
put "please enter the number of the first fraction: "..
get num1
put "please enter the denominator of the first fraction: "..
get dem1
put "please enter the number of the second fraction: "..
get num2
put "please enter the number of the second fraction: "..
get dem2
if dem1 not=dem2 then
var dem:int:=dem1*dem2
var num3:int:=dem2*num1
var num4:int:=num2*dem1
put num3+num4,"/",dem
elsif dem1=dem2 then
var num5:int:=num1+num2
put num5,"/",dem1
end if
end loop
how do you simply the fraction plz give the code to us !