From 54e474655cc318752f17d6a92b7f06e9f4011786 Mon Sep 17 00:00:00 2001 From: Muzzo <51519604+Muzzzo@users.noreply.github.com> Date: Sat, 16 Mar 2024 12:47:34 +0000 Subject: [PATCH 1/8] first task compete --- .vscode/settings.json | 3 +-- _01_02b/Employee.class | Bin 0 -> 592 bytes _01_02b/Employee.java | 13 +++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 _01_02b/Employee.class diff --git a/.vscode/settings.json b/.vscode/settings.json index 3fe1f5c..c122de0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -18,9 +18,8 @@ "files.autoSave": "afterDelay", "screencastMode.onlyKeyboardShortcuts": true, "terminal.integrated.fontSize": 18, - "workbench.activityBar.visible": true, "workbench.colorTheme": "Visual Studio Dark", "workbench.fontAliasing": "antialiased", "workbench.statusBar.visible": true, "java.server.launchMode": "Standard" -} +} \ No newline at end of file diff --git a/_01_02b/Employee.class b/_01_02b/Employee.class new file mode 100644 index 0000000000000000000000000000000000000000..657702e819cfa7334bf05dd48efd84074bda57c8 GIT binary patch literal 592 zcmZuu+e*Vg6r63-q>ZtSHmUJa@0UcxR)s*lp?CpBRH#(Z2Tf~`NRvoS1>gJ_e?T9q z_}~ZlQR3N(h+r1>Om=2=XU~3ozP$rjfh8k`xCB8#0wRNY?c6zqx)WR#4yxB~En*Ot zy}*lB8RDi@Ng;`p1X)1`lt1$F{cYs>qzap4()ZdMd12wO;RR7SYPgQSBqNQC1XV#7 zx*4+nXc(j$?x+V0g1KW=xJTm#oiChP6>&|V==5=>mot5w+2qXlHzTguKVbc#jUg?QwDE&xW)7Mi`+HYabf}<9(%hjQ;af8P&w}3)m9@1|FExKpZJdV3IJG zK0<&>^+e4tKSSzop;K5PFwjC)LvEL#)q>I0@oFbj(-!rFE?(FYE$b3#HT0K~8uBGs z!%#^vl7?I}lv*iG0wYbv-_sYVi=bDH(~HW;KtVUM$e{ Date: Sat, 16 Mar 2024 13:28:08 +0000 Subject: [PATCH 2/8] done-task2 --- _01_04/MenuBuilder.java | 11 +++++++++++ _01_04/MenuItem.class | Bin 0 -> 357 bytes 2 files changed, 11 insertions(+) create mode 100644 _01_04/MenuItem.class diff --git a/_01_04/MenuBuilder.java b/_01_04/MenuBuilder.java index aeaebc5..6c50e19 100644 --- a/_01_04/MenuBuilder.java +++ b/_01_04/MenuBuilder.java @@ -7,26 +7,37 @@ public static void main(String[] args) { // Create a variable called menuTitle of type String and assign it the value "My // Dream Menu:". + String menuTitle = "My Dream Menu:"; // Print the menuTitle variable to the console. + System.out.println(menuTitle); // Create a variable called menu of type ArrayList. + ArrayList menu = new ArrayList<>(); // Create a variable called starter of type MenuItem and pass in the name of // your favourite starter. + MenuItem starter = new MenuItem("Break Fast"); // Add the starter variable to the ArrayList called menu. + menu.add(starter); // Create a variable called mainCourse of type MenuItem and pass in the name of // your favourite main course. + MenuItem mainCourse = new MenuItem("Programming_in_java"); + // Add the mainCourse variable to the ArrayList called menu. + menu.add(mainCourse); // Create a variable called dessert of type MenuItem and pass in the name of // your favourite dessert. + MenuItem dessert = new MenuItem("Ubwali"); // Add the dessert variable to the ArrayList called menu. + menu.add(dessert); // Print the menu variable to the console. + System.out.println(menu); } } diff --git a/_01_04/MenuItem.class b/_01_04/MenuItem.class new file mode 100644 index 0000000000000000000000000000000000000000..a77cdef351b576ad39ed10191f66e9603a0e98e2 GIT binary patch literal 357 zcmZWlO-sW-5Pg$0NgLBfYdw1KmP9ZWy!mkv1flAo(rek&rEF<75H|f?3X0&tAK;G? zXY1FYEWDk0GjF~=KHuH}oMRBefg7L|!GllOUWk>*mqO3;yJ8_{hTxwmt;_|%P0~pR zZFB;J5w;K!;_2{sIy}j5q;9T_ED0?wN=fLC{tJywt@Qkqu$OGI>4Y_x)dOqdk<#+E zDGOQOi(<)4+f?6T!XQaE#e{HNHT6thDVyH?9plJ0#{tjk@Rr2L)3W8T?V-!qV=rUh x#>4CtlpVexcv@%2j6JxFd>6YfKfVlhesuf%6Gy%58NuV9#9x!Pc%L~3yI&w+LMQ+L literal 0 HcmV?d00001 From 51fc10e517da5316a3e8a8944079c6952f2d2eed Mon Sep 17 00:00:00 2001 From: Muzzo <51519604+Muzzzo@users.noreply.github.com> Date: Sat, 16 Mar 2024 14:00:15 +0000 Subject: [PATCH 3/8] Ticket.java --- _02_03b/Ticket.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 _02_03b/Ticket.java diff --git a/_02_03b/Ticket.java b/_02_03b/Ticket.java new file mode 100644 index 0000000..912827d --- /dev/null +++ b/_02_03b/Ticket.java @@ -0,0 +1,11 @@ +package _02_03b; + +public class Ticket { + private String destination; + private double price; + private boolean isReturn; + + public Ticket() { + + } +} From 31a7c522356132528730ea4a03a2d9a6962f3a8e Mon Sep 17 00:00:00 2001 From: Muzzo <51519604+Muzzzo@users.noreply.github.com> Date: Sat, 16 Mar 2024 14:02:17 +0000 Subject: [PATCH 4/8] Ticket changes --- _01_05b/MenuBuilder.java | 15 +++++++++++++-- _02_02/Ticket.class | Bin 0 -> 283 bytes _02_02/Ticket.java | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 _02_02/Ticket.class create mode 100644 _02_02/Ticket.java diff --git a/_01_05b/MenuBuilder.java b/_01_05b/MenuBuilder.java index cc35ba3..7e17c03 100644 --- a/_01_05b/MenuBuilder.java +++ b/_01_05b/MenuBuilder.java @@ -3,30 +3,41 @@ import java.util.ArrayList; public class MenuBuilder { + /** + * @param args + */ public static void main(String[] args) { // Create a variable called menuTitle of type String and assign it the value "My // Dream Menu:". + String menuTitle = "Dream Menu:"; // Print the menuTitle variable to the console. + System.out.println(menuTitle); // Create a variable called menu of type ArrayList. + ArrayList<> menu = new ArrayList<>(); // Create a variable called starter of type MenuItem and pass in the name of // your favourite starter. + MenuItem starter = new MenuItem("Jollof Rice"); // Add the starter variable to the ArrayList called menu. + menu.add(starter); // Create a variable called mainCourse of type MenuItem and pass in the name of // your favourite main course. + MenuItem mainCourse = new MenuItem("Ubwali"); // Add the mainCourse variable to the ArrayList called menu. - + menu.add(mainCourse); // Create a variable called dessert of type MenuItem and pass in the name of // your favourite dessert. + MenuItem dessert = new MenuItem("tagine"); // Add the dessert variable to the ArrayList called menu. - + menu.add(dessert); // Print the menu variable to the console. + System.out.println(menu); } } diff --git a/_02_02/Ticket.class b/_02_02/Ticket.class new file mode 100644 index 0000000000000000000000000000000000000000..c4bf5df3d1f626b4f0ca756b2cd1006d90e1a745 GIT binary patch literal 283 zcmYLE%T5A85Ukz@3%ekQU%*X0xW=o Date: Sat, 16 Mar 2024 14:19:47 +0000 Subject: [PATCH 5/8] Ticket main method complete --- _02_05b/Ticket.java | 19 ++++++++++++++++++- _02_06/TicketMachine.java | 8 +++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/_02_05b/Ticket.java b/_02_05b/Ticket.java index 339f8a0..33f7994 100644 --- a/_02_05b/Ticket.java +++ b/_02_05b/Ticket.java @@ -12,8 +12,25 @@ public Ticket() { // Add three public methods to set the value of each field, called // setDestination, setPrice and setIsReturn. + public void setDestination(String destination){ + this.destination = destination; + } + public void setPrice(double price){ + this.price = price; + } + public void setIsReturn(boolean isReturn){ + this.isReturn = isReturn; + } // Add three public methods to get the value of each field, called // getDestination, getPrice and getIsReturn. - + public String getDestination(){ + return destination; + } + public double getPrice(){ + return price; + } + public boolean getIsReturn(){ + return isReturn; + } } diff --git a/_02_06/TicketMachine.java b/_02_06/TicketMachine.java index 70c43e1..ea81940 100644 --- a/_02_06/TicketMachine.java +++ b/_02_06/TicketMachine.java @@ -4,18 +4,24 @@ public class TicketMachine { public static void main(String[] args) { // Create an object called ticket of type Ticket + Ticket ticket = new Ticket(); // Set the destination of the ticket to New York + ticket.setDestination("New York"); // Set the price of the ticket to 15.30 + ticket.setPrice(15.30); // Set the isReturn value to true - + ticket.setIsReturn(true); // Print the ticket's destination to the console + System.out.println(ticket.getDestination()); // Print the ticket's price to the console + System.out.println(ticket.getPrice()); // Print the ticket's isReturn value to the console + System.out.println(ticket.getIsReturn()); } From ec1ece93756eaf9156e55a68dd83b446328bb6a7 Mon Sep 17 00:00:00 2001 From: Muzzo <51519604+Muzzzo@users.noreply.github.com> Date: Sat, 16 Mar 2024 16:03:47 +0000 Subject: [PATCH 6/8] GradingSystem --- _02_07b/TicketMachine.java | 28 ++++++++++++++++------------ _03_03b/GradingSystem.java | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/_02_07b/TicketMachine.java b/_02_07b/TicketMachine.java index 77398c3..cb94eae 100644 --- a/_02_07b/TicketMachine.java +++ b/_02_07b/TicketMachine.java @@ -1,23 +1,27 @@ package _02_07b; public class TicketMachine { - -public static void main(String[] args) { - // Create an object called ticket of type Ticket - // Set the destination of the ticket to New York + public static void main(String[] args) { + // Create an object called ticket of type Ticket + Ticket ticket = new Ticket(); - // Set the price of the ticket to 15.30 + // Set the destination of the ticket to New York + ticket.setDestination("New York"); - // Set the isReturn value to true + // Set the price of the ticket to 15.30 + ticket.setPrice(15.30); - // Print the ticket's destination to the console + // Set the isReturn value to true + ticket.setIsReturn(true); + // Print the ticket's destination to the console + System.out.println(ticket.getDestination()); - // Print the ticket's price to the console - - // Print the ticket's isReturn value to the console - -} + // Print the ticket's price to the console + System.out.println(ticket.getPrice()); + // Print the ticket's isReturn value to the console + System.out.println(ticket.getIsReturn()); + } } diff --git a/_03_03b/GradingSystem.java b/_03_03b/GradingSystem.java index c8717c7..2950001 100644 --- a/_03_03b/GradingSystem.java +++ b/_03_03b/GradingSystem.java @@ -5,7 +5,12 @@ public class GradingSystem { public boolean isAPass(int percentage) { // Return true if the percentage is higher than or equal to 60. // Otherwise return false. - return false; + if (percentage >= 60) { + return true; + } else { + return false; + + } } public char getGrade(int percentage) { @@ -14,17 +19,41 @@ public char getGrade(int percentage) { // If it's 70-79, return 'C'. // If it's 60-69, return 'D'. // If it's less than 60, return 'F'. - return 'X'; + if (percentage >= 90) { + return 'A'; + } else if (percentage >= 80 && percentage <= 89) { + return 'B'; + } else if (percentage >= 70 && percentage <= 79) { + return 'C'; + } else if (percentage <= 60 && percentage <= 69) { + return 'D'; + } else if (percentage < 60) { + return 'F'; + } else { + return 'X'; + } } public String retakeMessage(int percentage, boolean allowedToRetake) { // If percentage is less than 60 and allowedToRetake is true, return a String + if (percentage < 60 && allowedToRetake == true) { + return "he student has been entered for a retake."; + } // that says "The student has been entered for a retake." // If percentage is less than 60 and allowedToRetake is false, return a String + if (percentage < 60 && allowedToRetake == false) { + return "he student is not allowed to retake this exam."; + } // that says "The student is not allowed to retake this exam." // If percentage is 60 or higher, return a String that says "A retake is not + if (percentage >= 60) { + return "A retake is not required"; + } // required." - return ""; + else { + return ""; + } + } } From 861a6b96a07c96911ea7481d3d0fec49e1f8ae49 Mon Sep 17 00:00:00 2001 From: Muzzo <51519604+Muzzzo@users.noreply.github.com> Date: Sat, 16 Mar 2024 16:45:29 +0000 Subject: [PATCH 7/8] loops --- _03_04/ForLoops.class | Bin 0 -> 515 bytes _03_04/ForLoops.java | 14 +++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 _03_04/ForLoops.class diff --git a/_03_04/ForLoops.class b/_03_04/ForLoops.class new file mode 100644 index 0000000000000000000000000000000000000000..ce23bb8ecee683ba63c9289ac1d890111a66b594 GIT binary patch literal 515 zcmZvZ%}&BV6ot=}LTN36ASnLu;|g3@65XM0Oh`yTO={Sj)#lkmy?z%Wy2WXPkBVcGqW! z9CDZY#|)uTxuqfsRe`2s2|7c(UD~Wf*WA zm(ZnO_Uu~-%-vqK++vVV#I;Q?Z*bQ>9S=ITcVTrL>c|6&lP*)bTr7;4zSX^LTEqFg zW{R=bwQD>O$Nn7H3!a4{*(8y{3|e3mRT90T8n$~pQ6dFsfJ 0; x--) { + System.out.println(x); + } } From 8ad814b04b418d9c4ad5b3718bf6cc4c93513598 Mon Sep 17 00:00:00 2001 From: Muzzo <51519604+Muzzzo@users.noreply.github.com> Date: Sat, 16 Mar 2024 17:14:52 +0000 Subject: [PATCH 8/8] java enhanced-loops --- _03_06/EnhancedForLoops.class | Bin 0 -> 1168 bytes _03_06/EnhancedForLoops.java | 11 +++++++++++ _03_07b/EnhancedForLoops.class | Bin 0 -> 1169 bytes _03_07b/EnhancedForLoops.java | 11 +++++++++++ 4 files changed, 22 insertions(+) create mode 100644 _03_06/EnhancedForLoops.class create mode 100644 _03_07b/EnhancedForLoops.class diff --git a/_03_06/EnhancedForLoops.class b/_03_06/EnhancedForLoops.class new file mode 100644 index 0000000000000000000000000000000000000000..aab70b9796c2017f93539512decc9eec0055248a GIT binary patch literal 1168 zcmZuwOHb5L6#g!A+dB+J>Wl>k1>ZX8z@X@;3?ld-k_=Om5>0hs3RI~=OFA7RYhAfC zapBgOxYmWQC^2#8Z*XCv8{#zgVl!r)+Rn)^8SJLi7qJLkUt{b~uo37k!#2?+tN zL4nGkUw3Xgg*nH+RxqcoyVDVaI^_9YG|Z65^;~F163qfB4K2{t!L7w=<2@GyHm$!WqT_2xv=g(5 zz@Kpzlh{mNlQp**Z#o&8FS;}S>UJwba&op7t{irg*I4KgFoo^dA+S@!F6^$~P>Z~| z!e|&ei&X+T)v{NmWcK7PucXtUOQ~nY6njWmsRetnPavnE2m2W|#L2B46ALeLLnjJC zhW1>e_xP%vBIMC4(5In*eunhl2z3bMIqOs_?k!?P<+vn04rv&`VN%PF&71168_7!H zi&FKYRGM5vGE^8+vm|9c&d_nCf8a`gv2fO(b^K{}W-JKHL9jqt@YBJJ%g|Q#e791Y zpK`-VXKIcteBSY>RPE~|T8qliYDLcUjR|KV#tV#4*&Eedg$kTvXu3Skkg|eWIPH#k zGP?0ElRl{lcHkJbt^At6WaH8}NV_hY8O_T6=U`80!BC=69?P*AL)7vyl-&lWRtCQ7 z$=4}6p_n#TOVBYjY7|urQt-88@%fwI`RhZD=JSR z4CNVG?{M~b`AhN*GIk(-hPmg&78qU#NK^p>Ul)Fgd9x}KO z1MjdIACSc-bmA+mzo8q$+PpOMZ#ko_g!!CrywmNL< M52_o(>6px!Ka21H-T(jq literal 0 HcmV?d00001 diff --git a/_03_06/EnhancedForLoops.java b/_03_06/EnhancedForLoops.java index 0008f6d..c590923 100644 --- a/_03_06/EnhancedForLoops.java +++ b/_03_06/EnhancedForLoops.java @@ -8,13 +8,24 @@ public class EnhancedForLoops { public static void main(String[] args) { int[] primeNumbers = { 2, 3, 5, 7, 11, 13, 17, 19 }; // Write an enhanced for loop to print out each prime number in the array. + for(int prime:primeNumbers){ + System.out.println(prime); + } List weekDays = Arrays.asList("Monday", "Tuesday", "Wednesday", "Thursday", "Friday"); // Write an enhanced for loop to print out each week day in the list. + for(String weekDay:weekDays){ + System.out.println(weekDay); + } int[] randomNumbers = { 23, 51, 72, 84, 1, 60, 34, 102 }; // Write an enhanced for loop to print out the numbers in the array that are // greater than 50. + for(int rand:randomNumbers){ + if (rand > 50){ + System.out.println(rand); + } + } } diff --git a/_03_07b/EnhancedForLoops.class b/_03_07b/EnhancedForLoops.class new file mode 100644 index 0000000000000000000000000000000000000000..262384de0c837270950cf341ef19176550fa4c09 GIT binary patch literal 1169 zcmZuwOHb5L6#g!A+dB+J>Og@}!M6@FFeo}IgZL(r3{#U5Ol4sTRH#BrIvpcxUAZ)I z;ntYA)`hPqF>&W_aABew<4RY?MDg6h=wNJ``#ASI=YHoq=f3;(as|K%oKK+v2?4G_ zfy$s?b8a~K1;?Muo730anTSCh_IxiIVMt_qCL57Nqd-bS6SNI*Yq=7+i-ZcQ^p4tu7$Xm#t z4nt?TLO`cd@+y?f-t5#`I(51fd)7>`hlCZIun+qMvKo4DfMHXd+@E7&;YDufL_x^V zo~`#DTenk$9Qp+MHRLhCkp3H?2BAFXol4ogNvx819Sy=#5G;`x{A@7mGPIOD-z`@c zr`>SEnO-0ZUvxaGRr>~w{)A;{wjyWd`na#Dw)MxnQwrQY$}%1ENX4c_$t9XW&d7nCOu zhVm56w>f*X`Z@U;t#%@9ST;|0ShkYRShkwpYS|*)Wj)9C@!SjSWhnQ(Krh36WN2}a z;SE}cI7Q0vr#SLx_0t+Dy@OckgG5WeAbCv?FD_{f$Fz3Ew62=vz9F9BD+MJ{Pz}{k z9$@U9{mI z47^1r-XnvL*n%&#{)%plkmpH=RUC#Qa8lqj{fu<}j?7Q_5cUb=exQ4mN+oIlvejVQ NzEj;8&c weekDays = Arrays.asList("Monday", "Tuesday", "Wednesday", "Thursday", "Friday"); // Write an enhanced for loop to print out each week day in the list. + for(String weekDay :weekDays){ + System.out.println(weekDay); + } int[] randomNumbers = { 23, 51, 72, 84, 1, 60, 34, 102 }; // Write an enhanced for loop to print out the numbers in the array that are // greater than 50. + for(int rand:randomNumbers){ + if(rand > 50){ + System.out.println(rand); + } + } }