CSC 190 Lecture Notes - Lecture 4: Rational Number

7 views2 pages

Document Summary

//purpose: read a rational number like 10/3 and print it. //in proper format like 3 1/3. import java. util. scanner; public class p0121a { public static void main(string[] args) { Scanner in = new scanner(system. in); int numin, den; //input int whole, numout; //output. System. out. print("enter denominator: "); den = in. nextint(); whole = numin/den; numout = numin%den; System. out. println(numin + "/" + den + " = " + whole + " " + numout + //prints the area and circumference of the circle import java. util. scanner; public class p0121b { public static void main(string[] args) { Scanner in = new scanner(system. in); double cx, cy, radius; double area, circum; System. out. print("enter x-coordinate of the center point of the circle: "); cx = in. nextdouble(); System. out. print("enter y-coordinate of the center point of the circle: "); cy = in. nextdouble(); System. out. print("enter the radius of the circle: "); radius = in. nextdouble(); circum = 2*math. pi*radius; area = math. pi*radius*radius;

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions