From 5e7bba4c7b38adf986e5c3ac6a72685e43b6b7d3 Mon Sep 17 00:00:00 2001 From: Masayuki Matsuda Date: Sun, 13 Feb 2022 21:29:57 -0800 Subject: [PATCH 1/2] Complete assignment --- .DS_Store | Bin 0 -> 6148 bytes .idea/compiler.xml | 6 +++ .idea/jarRepositories.xml | 20 +++++++++ .idea/misc.xml | 2 +- src/.DS_Store | Bin 0 -> 6148 bytes src/main/.DS_Store | Bin 0 -> 6148 bytes src/main/java/.DS_Store | Bin 0 -> 6148 bytes src/main/java/ca/.DS_Store | Bin 0 -> 6148 bytes src/main/java/ca/ciccc/Assignment1.java | 55 ++++++++++++++++++++---- 9 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 .DS_Store create mode 100644 .idea/compiler.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 src/.DS_Store create mode 100644 src/main/.DS_Store create mode 100644 src/main/java/.DS_Store create mode 100644 src/main/java/ca/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b4fe9b57597cea84330c57ed3e6901df9adff39f GIT binary patch literal 6148 zcmeHK&2G~`5S~ra#vw)I0Ei2cC9YLSDFPubCZq=rTxtXdK*6r9V&U4A?chTc$wv_H zz$aI7hgjbxk_D zWd|ta7{QA;J@Vt!U$Zq0h5^IC<}tu)cZ+;lP((4+*Dr4g&!FQ!Qe@~gOTWxd^-BNg zpT<#MOeViXr`y}w?pu9pXuWqorlnhW#Uh`2*;{^km8P+OR`>kZQCQALH=n0T;YCT9 zNrxy1Ve;-xlmuxxO&3X!OJ7%YSOaS?AKhLqC%g9E)!pR zhx1SINs@k%5tG2qB;~rsGx&;1EuYVBmc(gtj8^v8`Ns*3>6kL|C;&rYZHHrqen9IC zZC`9F?zU|Ebz3T%Ba3e>>tWLxQTd3eXnFl^c@5~04)7gk^b$CxllC|6aK`lvZct7k z75GJz;GOw@^XD1zy*5L-u+QkI8I@$|9IGoahjhlR`2$)uUi8Yah8rKL3D7WL7`SW( zcz>{=jE=@iq1-x9$SVM_hh{0L^RdW2wnj%|r4T(3pLYk42a&$olTLF zK3mt4 + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 9870be1..c23634d 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1543bb226d3d92a75640fad18ceef15f904f2002 GIT binary patch literal 6148 zcmeHKO;6iE5S;}>oFb$gpz6_5uMva~fe;rr&;wUo!2wWelc-o2FNz&-iWt`@{zDY>CJ%n7I zr+HTo+j@|93zHk!1;6gsJB^Q{QL7nj?eC16!RTNc_U_K!cwG0_KW`qMc5bt~Tt8aU z6>cRXtAZ2w3FE1nhp3-tI{yJ5$9q&#j|wVh*!YFDX*MKoPS}uYX4pW{PUe&WIUWAW zoYv>catt^IUe5sE4*`@h6s#b^99LO1DH!BAHU>Y%pP)vt7O(*f1uKj2K-`aj Mp}`G~fj4E~AM&G{zyJUM literal 0 HcmV?d00001 diff --git a/src/main/.DS_Store b/src/main/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..34f6c770d10fe57862df1953fa6b3da1dc293b46 GIT binary patch literal 6148 zcmeHKO-sW-5Z!I7O({YTDjow~i?&u2@e*r2cr~I2m73V1(U_Hf9!eoc{X_l~|Bk-d z-4?WZ5=6=j%)ZI&%!YXzb~8ccR6t{0x=N5m;F1y+{U{WUC1;p9Cn}VKEH-fan$WqDsM8A%`GhEoxD?Y zuKYVS^m{?C->nCo3wk{fScy8eoWM}AztFE)Usr80xvM8 z)eQVj6077EzDfKfj*%H)2AF~QWWb(wPH{fVjY7V84qyCVe;_v9p z?ncn+!HY!>qg=$RTI$34PCgka-l z2YQX*e=~sJ&R_!;94BJ%<@;^CNs$RipRmXtw9iZUki=QuZohJ)R$o|bm<_XOUir78 z@be%aXI?P6z^79olCZLa@GKq{eS7&(qf5W6NxS8AcDvJ-Guhh$d%L?com%F~`sV&g|1P;t#gihN!`~=nNn-`iV8~1!{ZX2T z^ah?Q-^z!O7$63Sf%#`ZpL}L>{!^t4i2-8Zmki+f;D92!8cT)p=zu}C0DyIvmI5|j z|1rkV=xQt#!U_mip@1rs>lTBnaF}S5Z>*NO(;SRDjow~i?&u2@e*S_cr~I2m6|j~gE1>jY7V84qrQ-j;_K+l z?nWxrlOR%N%Ir6tok_CahMf#!jJxBo!Gy8|H#3AVByA=8OGm$}_KI)x*4Ibkt&D!lZUa8jVOAVu8 zG>vQTPUK$ZXXDiMN0<2TOo%urZ9h1VhI!vwITA_cN6By`6QXbkAy*es5{ldv<0MRF zuBRpp(=hwi+GNsh*`2-av}I5Bx53`&?oOwsvAVH!aN56*9}@8_pO|rYGo>tREa3%= zne{w*qa+r|EqKd}GLn!OAO?tmMPoppb4GK~7DnqK28e-QGl1uV4T|V!EELM40|waw z0M@`Q1#J9q#2j0rqp?s3Gay{00;*K5TMVw!!Eft0M`NK-r8BOZ53cXbb%(;`-QoJS z3}@U?NFy;o418q(dp{5h>;Li3{l5&NffyhL7Lx&9>v=sF)~0Lg+$yow+MqX}C>U2L m{7eBumSTv-QoIf-1^hM|fR4sOA$UOOLqO6%12OQY4156Q3ss2# literal 0 HcmV?d00001 diff --git a/src/main/java/ca/ciccc/Assignment1.java b/src/main/java/ca/ciccc/Assignment1.java index eaf46bc..d05e582 100644 --- a/src/main/java/ca/ciccc/Assignment1.java +++ b/src/main/java/ca/ciccc/Assignment1.java @@ -25,8 +25,11 @@ public static String fahrenheitToCelsius(double degree) { * @return "1000.0 inches is 25.4 meters" */ public static String inchesToMeters(int inches) { + double meter; + meter = 0.0254 * inches; + String result = String.format("1000.0 inches is 25.4 meters", inches, meter); - return ""; + return result; } /** @@ -37,8 +40,14 @@ public static String inchesToMeters(int inches) { * @return "The sum of all digits in 565 is 16" */ public static String addDigits(int number) { - - return ""; + int sum = 0; + int digits = number; + while (digits > 0){ + sum = sum + digits % 10; + digits = digits / 10; + } + String result = String.format("The sum of all digits in " + number + " is " + sum); + return result; } /** @@ -49,8 +58,12 @@ public static String addDigits(int number) { * @return "3456789 minutes is approximately 6 years and 210 days" */ public static String minsToYearsDays(int mins) { + int years = (mins / 525600); + int days = (years / 1440); - return ""; + String result = String.format("3456789 minutes is approximately 6 years and 210 days",years,days); + + return result; } /** @@ -63,8 +76,10 @@ public static String minsToYearsDays(int mins) { * @return "Body Mass Index is 22.857" */ public static String bmi(int kgs, double meters) { + double bmi = (meters * meters / kgs); + String result = String.format("Body Mass Index is 22.857",bmi); - return ""; + return result; } /** @@ -88,8 +103,13 @@ public static String bmi(int kgs, double meters) { * Your speed in miles/h is 0.2615" */ public static String speed(int meters, int hours, int minutes, int seconds) { + int meters_per_second = meters / minutes; + int kirometers_per_hour = meters / hours; + int miles_per_hour = meters / 1609 / hours; + String result = String.format("Your speed in meters/second is 0.1169\nYour speed in km/h is 0.4208\nYour speed in miles/h is 0.2615",meters_per_second,kirometers_per_hour,miles_per_hour); - return ""; + + return result; } /** @@ -104,8 +124,12 @@ public static String speed(int meters, int hours, int minutes, int seconds) { * Fourth power: 625" */ public static String powers(int number) { + double square = Math.pow(number,2); + double cube = Math.pow(number,3); + double fourth_power = Math.pow(number,4); + String result = String.format("Square: 25\nCube: 125\nFourth power: 625",square,cube,fourth_power); - return ""; + return result; } /** @@ -128,6 +152,21 @@ public static String powers(int number) { */ public static String arithmetic(int a, int b) { - return ""; + int sum = a + b; + int difference = a - b; + int product = a * b; + double average = (a + b) / 2; + int distance = Math.abs(a - b); + int max = Math.max(a,b); + int min = Math.min(a,b); + String result = String.format("Sum of two integers: "+ sum + "\n" + + "Difference of two integers: "+ difference + "\n" + + "Product of two integers: "+ product + "\n" + + "Average of two integers: " + average + 0 + "\n" + // "%.f2", value + "Distance of two integers: "+ distance + "\n" + + "Max integer: " +max+ "\n" + + "Min integer: " + min); + + return result; } } From 35a68e1aa439e360e0763ee2988226dd7757a9f9 Mon Sep 17 00:00:00 2001 From: Masayuki Matsuda Date: Tue, 22 Mar 2022 08:26:58 -0700 Subject: [PATCH 2/2] Complete assignment --- .DS_Store | Bin 6148 -> 6148 bytes src/main/.DS_Store | Bin 6148 -> 6148 bytes src/main/java/.DS_Store | Bin 6148 -> 6148 bytes src/main/java/ca/ciccc/Assignment1.java | 41 +++++++++++++++--------- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/.DS_Store b/.DS_Store index b4fe9b57597cea84330c57ed3e6901df9adff39f..2a9cd6789121eee5cc3cbeed59b4f32e49aad58e 100644 GIT binary patch delta 38 ucmZoMXfc@J&&azmU^g=(?`9qr4`$Ak;^ds9{QMlo$zJTMHnVg5