Skip to content

Commit 0116617

Browse files
authored
Merge pull request #14 from rollingjizas/main
Grosspay Java Inheritance
2 parents 4cb5351 + 714815a commit 0116617

File tree

5 files changed

+318
-0
lines changed

5 files changed

+318
-0
lines changed
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
5+
int main(){
6+
7+
8+
int runner =0;
9+
int pick;
10+
while(runner==0){
11+
12+
cout << "\n";
13+
cout << "----------------------------------" << "\n";
14+
cout << "+___________MAIN MENU____________+" << "\n";
15+
cout << "----------------------------------" << "\n";
16+
cout << "+ [1.] One-Dimentional Array +" << "\n";
17+
cout << "+ [2.] Multi-Dimentional Array +" << "\n";
18+
cout << "+ [3.] E X I T +" << "\n";
19+
cout << "==================================" << "\n";
20+
cout << " Please select an Operation [1-3]" << "\n";
21+
cin >> pick;
22+
switch(pick){
23+
24+
case 1: {
25+
cout << "\n";
26+
cout << "= = = One-Dimentional Array = = =" << "\n";
27+
28+
int put1;
29+
int ray[5];
30+
int put;
31+
cout << " Enter # of Elements: ";
32+
cin >> put;
33+
34+
35+
for(int exodia=0; exodia<put; exodia++){
36+
cout << " " << "[ " << " " << exodia << " " << " ]";
37+
cin >> ray[exodia];
38+
}
39+
cout << "\n";
40+
cout << "===================================" << "\n";
41+
cout << "= [ 1 ] D E L E T E =" << "\n";
42+
cout << "= [ 2 ] S E A R C H =" << "\n";
43+
cout << "= [ 3 ] U P D A T E =" << "\n";
44+
cout << "===================================" << "\n";
45+
cout << "Enter an Operation [1-3]: ";
46+
47+
48+
cin >> put1;
49+
50+
switch(put1){
51+
52+
case 1:{
53+
char pili1;
54+
55+
56+
cout << " Enter Index Pos. to Delete: ";
57+
int erad;
58+
cin >> erad;
59+
int rase=erad;
60+
while(rase < put){
61+
ray[rase-1]=ray[rase];
62+
rase=rase+1;
63+
}
64+
put=put-1;
65+
for(int eyodia=0; eyodia<put; eyodia++){
66+
cout << " " << ray[eyodia] << " ";
67+
cout << " ";
68+
69+
70+
}
71+
cout << "\n";
72+
cout << "\n";
73+
74+
break;
75+
76+
77+
}
78+
79+
case 2:{
80+
int ser;
81+
cout << " Enter # to Search in the Elements: ";
82+
int find;
83+
cin >> find;
84+
ser=0;
85+
while(ser < put ){
86+
if(ray[ser]==find){
87+
break;
88+
}
89+
ser=ser+1;
90+
}
91+
cout << " The Position of " << find << " is " << ser << " \n ";
92+
cout << " \n ";
93+
break;
94+
}
95+
case 3:{
96+
int upd;
97+
cout << "Enter # Position to Update: ";
98+
cin >> upd;
99+
cout << "Enter #: ";
100+
int updnum;
101+
cin >> updnum;
102+
ray[upd-1]=updnum;
103+
for(int ewodia=0; ewodia<put; ewodia++){
104+
cout << ray[ewodia] << " ";
105+
106+
}
107+
108+
}
109+
}
110+
break;
111+
}
112+
113+
114+
115+
116+
117+
case 2: {
118+
int put2;
119+
int ray[2][3];
120+
int hori,verti;
121+
cout << "\n";
122+
cout << "* * * Multi-Dimentional Array * * *" << "\n";
123+
124+
cout<< "Enter # of Row: ";
125+
cin >> hori;
126+
cout << "Enter # of Column: ";
127+
cin >> verti;
128+
129+
for(int exodia=0; exodia<hori; exodia++){
130+
for (int eyodia=0; eyodia<verti; eyodia++){
131+
132+
cout << " [ " << exodia << " ]" << "[ " << eyodia << " ]";
133+
cin >> ray[exodia][eyodia];
134+
135+
}
136+
}
137+
cout << "\n";
138+
cout << "* * * Multi-Dimentional Array * * *" << "\n";
139+
cout << "***********************************" << "\n";
140+
cout << "* [ 1 ] S E A R C H *" << "\n";
141+
cout << "* [ 2 ] U P D A T E *" << "\n";
142+
cout << "***********************************" << "\n";
143+
cout << "Enter an Operation [1-2]: ";
144+
cin >> put2;
145+
146+
switch(put2){
147+
case 1:{
148+
149+
int find;
150+
cout << " Enter # to Search: ";
151+
cin >> find;
152+
153+
154+
155+
for(int exodia=0; exodia<hori; exodia++){
156+
for (int eyodia=0; eyodia<verti; eyodia++){
157+
if(ray[exodia][eyodia]==find){
158+
cout << " The # " << find << " is in the Pos. of: " << exodia << " " << eyodia;
159+
cout << "\n";
160+
}
161+
}
162+
}
163+
break;
164+
}
165+
166+
167+
case 2:{
168+
169+
int repl, rr, cc;
170+
cout << " Enter # of Row & Column to Update: " << " \n";
171+
cout << " Row: ";
172+
cin>> rr;
173+
cout << " Column: ";
174+
cin>> cc;
175+
176+
cout << "Enter # to Replace: ";
177+
cin >> repl;
178+
179+
ray[rr][cc]=repl;
180+
for(int exodia=0; exodia<hori; exodia++){
181+
for (int eyodia=0; eyodia<verti; eyodia++){
182+
cout << ray[exodia][eyodia] << " ";
183+
184+
}
185+
186+
}
187+
cout << "\n";
188+
break;
189+
}
190+
exit(0);
191+
}
192+
193+
break;
194+
195+
}
196+
197+
198+
199+
200+
201+
202+
203+
default:
204+
cout << "Error Operation only [1-3]" << " \n ";
205+
runner = true;
206+
cout << " \n ";
207+
}
208+
cout << "\n";
209+
cout << "Back to the Main Menu? Yes[0] || [1]No ";
210+
cin >> runner;
211+
212+
if(runner==0){
213+
system("cls");
214+
runner=0;
215+
216+
}else {
217+
runner=1;
218+
exit(0);
219+
220+
221+
}
222+
}
223+
224+
return 0;
225+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
3+
4+
5+
public class AEmployeeRecord extends BEmployeeSalary{
6+
7+
public void record(String empname, String empstat, String empded){
8+
System.out.println(" |---------------------------------|");
9+
System.out.println(" |Employee Name: " +empname);
10+
System.out.println(" |Employee Status: " + empstat);
11+
System.out.println(" |Department: " + empded);
12+
System.out.println(" |---------------------------------|");
13+
}
14+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
public class BEmployeeSalary extends CemployeeDeduction{
2+
3+
public void salary(int prate, int hrswrked, int clothing, int transpo, int food){
4+
5+
int employeesalary =(prate * prate)+(clothing +transpo+ food);
6+
System.out.println(" |Employee Netpay: " +employeesalary);
7+
System.out.println(" |---------------------------------|");
8+
}
9+
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
3+
public class CemployeeDeduction {
4+
5+
public void deductionsyow(int sssded, int loveded, int taxded){
6+
7+
int deducted= sssded+ loveded + taxded;
8+
System.out.println(" |Employee Deduction Overall: " + deducted);
9+
System.out.println(" |---------------------------------|");
10+
System.out.println(" |=================================|");
11+
System.out.println(" |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|");
12+
System.out.println(" |_________________________________|");
13+
}
14+
}

Inheritance Java/Main.java

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
3+
import java.util.Scanner;
4+
5+
6+
public class Main {
7+
8+
9+
public static void main(String[] args) {
10+
11+
Scanner pasok =new Scanner(System.in);
12+
System.out.println(" _____________________________");
13+
System.out.println(" |_____________________________|");
14+
System.out.println(" |------ G R O S S P A Y ------|");
15+
System.out.println(" |-----------------------------|");
16+
System.out.println(" | |");
17+
System.out.print (" |Employee Name: ");
18+
String empname =pasok.nextLine();
19+
System.out.print (" |Employee Status: ");
20+
String empstat =pasok.nextLine();
21+
System.out.print (" |Employee's Department: ");
22+
String empdep =pasok.nextLine();
23+
System.out.println(" |=============================|");
24+
System.out.print (" |Pay-Rate: ");
25+
int prate =pasok.nextInt();
26+
System.out.print (" |# of House Worked: ");
27+
int hrswrked =pasok.nextInt();
28+
System.out.print (" |Clothing Allowance: ");
29+
int clothing =pasok.nextInt();
30+
System.out.print (" |Transportation Allowance: ");
31+
int transpo =pasok.nextInt();
32+
System.out.print (" |Food Allowance: ");
33+
int food =pasok.nextInt();
34+
System.out.println(" |=============================|");
35+
System.out.print (" |SSS Deduction: ");
36+
int sssded =pasok.nextInt();
37+
System.out.print (" |Pag-Ibig Deduction: ");
38+
int loveded =pasok.nextInt();
39+
System.out.print (" |Tax Deduction: ");
40+
int taxded=pasok.nextInt();
41+
System.out.println(" |=============================|");
42+
System.out.println("");
43+
System.out.println(" _________________________________");
44+
System.out.println(" |_________________________________|");
45+
46+
47+
AEmployeeRecord Emprec =new AEmployeeRecord();
48+
49+
Emprec.record(empname, empstat, empdep);
50+
Emprec.salary(prate, hrswrked, clothing, transpo, food);
51+
Emprec.deductionsyow(sssded, loveded, taxded);
52+
53+
}}
54+
55+

0 commit comments

Comments
 (0)