2002-2-mt - 2002-2 Midterm CMPT 1011. A rational number is...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 2002-2 Midterm CMPT 1011. A rational number is any number of the fora/bwherea,bare integers. Programming lan-guages do not generally support a rational number data type. The following five parts of thisquestion require you to develop and use teh following rational number data type.Read allparts of this question before attempting part aGenerally, rational numbers must bereduced,Do not concern yourself with reduction in this problem.The following is part of a Java implementation of the ADTRationalTypeclass RationalType{private int num;private int dem;public RationalType(); // initialize to 0public RationalType(int a, int b); //initialize to a/bpublic int giveNumerator();public int giveDenominator();public void setRational(int a, int b); //set to a/b where bneqpublic void input(); // input with no promptspublic void output(); //output to screen no promptspublic void absolute(); //take absolute valuepublic void negate(); //multiply by -1public void add(RationalType x); //add x to invoking number...
View Full Document

This note was uploaded on 01/16/2010 for the course CMPT 101 taught by Professor Various during the Spring '03 term at Simon Fraser.

Page1 / 2

2002-2-mt - 2002-2 Midterm CMPT 1011. A rational number is...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online