ANS:-
Ex1.java
public class Ex1 {
public static void main(String[] args) {
FractionUtilityZhiyingL.menuHw5();
}
}
FractionZhiyingL.java
class FractionZhiyingL {
private int num;
private int denom;
public FractionZhiyingL() {
num = 0;
denom = 1;
}
public FractionZhiyingL(int n, int d) {
int gcd;
if (n != 0) {
num = n;
denom = d;
gcd = getGCD();
if (d < 0) {
num = -n / gcd;
denom = -d / gcd;
}
else {
num = n / gcd;
denom = d / gcd;
}
}
else {
num = 0;
denom = 1;
}
}
public FractionZhiyingL add(FractionZhiyingL
f) {
return new
FractionZhiyingL(num * f.denom + denom * f.num,
denom * f.denom);
}
public FractionZhiyingL
subtract(FractionZhiyingL f) {
return new
FractionZhiyingL(num * f.denom - denom * f.num,
denom * f.denom);
}
public FractionZhiyingL
multiply(FractionZhiyingL f) {
return new
FractionZhiyingL(num * f.num, denom * f.denom);
}
public FractionZhiyingL
divide(FractionZhiyingL f) {
return new
FractionZhiyingL(num * f.denom, denom * f.num);
}
public int getNum() {
return num;
}
public int getDenom() {
return denom;
}
public void setNum(int n) {
int gcd;
if (n != 0) {
num = n;
gcd = getGCD();
num /= gcd;
denom /= gcd;
}
else {
num = 0;
denom = 1;
}
}
public void setDenom(int d) {
int gcd;
if (num != 0) {
denom = d;
gcd = getGCD();
if (denom < 0) {
num = -num / gcd;
denom = -denom / gcd;
}
else {
num = num / gcd;
denom = denom / gcd;
}
}
else {
denom = 1;
}
}
public void print() {
System.out.println("
num: " + num + "\n denom: " + denom);
}
public void update(int n, int d) {
int gcd;
if (n != 0) {
num = n;
denom = d;
gcd = getGCD();
if (d < 0) {
num = -n / gcd;
denom = -d / gcd;
}
else {
num = n / gcd;
denom = d / gcd;
}
}
else {
num = 0;
denom = 1;
}
}
public int[] getCommonDigit() {
int[] returnAry;
int[] numDigitAry;
int[]
denomDigitAry;
int tmp;
int size = 0;
tmp = num < 0 ?
-num : num;
numDigitAry = new
int[10];
do {
numDigitAry[tmp % 10] = 1;
tmp /= 10;
} while (tmp != 0);
tmp = denom;
denomDigitAry = new
int[10];
do {
denomDigitAry[tmp % 10] = 1;
tmp /= 10;
} while (tmp != 0);
for (int i = 0; i
< 10; i++) {
if (numDigitAry[i] == 1 && denomDigitAry[i] == 1) {
size++;
}
}
returnAry = new int[size];
if (size != 0)
{
for (int i = 0, j = 0; i < 10; i++) {
if (numDigitAry[i] == 1 && denomDigitAry[i] == 1) {
returnAry[j] = i;
j++;
}
}
}
return
returnAry;
}
protected final int getGCD(int a, int b)
{
if (b != 0)
return getGCD(b, a % b);
else
return a;
}
protected final int getGCD() {
int a = num < 0 ?
-num : num;
int b = denom < 0 ?
-denom : denom;
int tmp;
while (b != 0)
{
tmp = a % b;
a = b;
b = tmp;
}
return a;
}
}
note:
due to limited character i cant able to post this file
FractionUtilityZhiyingL.java
CIS25-C++ Programming; Homework #5-Page 6 of 9 Wrong option! which Point to be checked against (1...
C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...
1.178 is wrong
College Physics 1e LS HW 8 HW 8 (1 of 12) 2)(3)(4)(5)(6)(7)(8)(9)(10)(〉) TimeSpent 00:02:45 1: In the course of 2.25 h, what is the angular displacement of the hour hand of a clock? Take counterclockwise to be the positive direction. 1.178 rad
Save Homework: Chapter 5 Homework Score: 0 of 1 pt 6 of 15 (5 complete) HW Score: 20%, 3 of 15 pts X Exercise 8 Question Help As the owner of a family farm whose wealth is $300,000, you must choose between sitting this season out and investing $200,000 in a safe money market fund paying 7 percent option 1) or planting summer com (option 2). Planting costs $200,000, with a six-month time to harvest. If there is rain, planting...
Page 1 Question 5 (1 point) Which of the following statements is/are CORRECT? 1) A proxy is a document giving one party the authority to act for another party, including the power to vote shares of common stock. 2) The preemptive right gives the current bondholders the right to purchase, on a pro rata basis, any new shares issued by the firm. 3) The preemptive right helps to protect stockholders against both dilution of control and dilution of value. 4)...
c++ problem You are asked to implement a car ordering system for Bobcats Auto Dealership. This dealership is brand new and only sells one brand of cars with three different models. However, a buyer can add options if they choose. Write a C++ program that allows the user to order a single car with different options. All the options available will be stored in a file called "options.txt" along with their cost. You may assume that the file will not...
C++ program that could be used to track, by lab, who is
logged into which computer
1. |15 points| Suppose you run four computer labs. Each lab contains computer stations that are numbered as shown in the table below Lab Number |Computer Station Numbers 1-5 2 1-4 1-3 Each user has a unique five-digit ID number. Whenever a user logs on, the user's ID, lab number, and the computer station number are transmitted to your system. For instance, if user...
Question 36 (1 point) Which two amongst the five following statements are wrong? 1) A stent can be used to treat restenosis 2) A lysis of the lumen by rotational ablation is desirable before inserting a stent 3) Catheter with very large outer diameter must be used in angioplasty 4) Devices such as expandable balloons can be used in angioplasty before inserting a stent 5) XeCl excimer laser has never been used clinically to remove atherosclerotic plaque in angioplasty. 1)...
Question 36 (1 point) Which two amongst the five following statements are wrong? 1) A stent can be used to treat restenosis 2) A lysis of the lumen by rotational ablation is desirable before inserting a stent 3) Catheter with very large outer diameter must be used in angioplasty 4) Devices such as expandable balloons can be used in angioplasty before inserting a stent 5) XeCl excimer laser has never been used clinically to remove atherosclerotic plaque in angioplasty 1)...
Question 7 (1 point) Use first differences to determine which option below shows a non-linear relationship. O 9 V 1 1 9 2 5 3 1 4 -3 9 V 1 -1 2 N 3 6 4 11 O 9 V 1 5 2 7 3 9 4 11 o 49 V -3 -3 1 2 3 4 3 3
Question 9 (1 point) Labor 0 0 Using the above table, the hiring of which worker marks the start of the law of diminishing returns? OA) 1st worker (moving from 0 to 1) O B) 2nd worker (moving from 1 to 2) O C) 3rd worker (moving from 2 to 3) OD) 4th worker (moving from 3 to 4) OE) 5th worker (moving from 4 to 5)