***Please help!! This is the third time I\'m posting this question*** ***All the
ID: 3795350 • Letter: #
Question
***Please help!! This is the third time I'm posting this question*** ***All the instructions, sample output and previous HW5 paystub are down below please scroll down to view them.***
HW6: Paystub for Employee CSS 161 Fundamentals of Computing By: Hansel Ong Summary So far you have kept track of hours worked for only one employee. However, this is obviously not sustainable as companies typically have more than one employee some companies even have over 100,000 employees! Let's use the object-oriented programming (OOP) paradigm to simplify data collection and storage Estimated Work Needed This assignment took me about 30-45 minutes to write (not including challenges, but including testing, commenting, and cleanup) in less than 200 lines of code (total across three Java files) In other words, you should expect to spend between 135 to 450 minutes working on this assignment. If you've spent more than 7.5 hours working on this assignment, then you are likely struggling with arrays, loops, basic class design, methods, and the use of the new scope and should re-read the lecture slides (and attempt the exercises within), seek help from your fellow classmates, myself, your lab instructor, QSC tutor, as well as online resources. Skills Expected All the skills from previous Assignment(s) Class Object and Design, including but not limited to o Instance Variables o Getter and Setter (including input validation in Setters o Constructor o Methods Assignment Description You will write three Class objects (and subsequently submit three .java files): Paystub Employee EmployeeDriver Notes: ONLY the EmployeeDriver class should have static methods. · All the other classes should NOT have static methods or instance variables. Constants should still be static final The below is the minimum you must include-you could include additional instance variables, methods, etc. as you needExplanation / Answer
//EXAMPLE PROGRAM FOR SINGLE LINKED LIST
# include <stdio.h>
# include <conio.h>
# include <alloc.h>
# include <stdlib.h>
struct list
{
int number;
struct list *next;
};
typedef struct list node;
node *first,*prev,*temp,*curr;
void create(void)
{
printf(" Stop by -999");
temp=(node *)(malloc(sizeof(node)));
printf(" Enter the numbers ");
scanf("%d",&temp->number);
while(temp->number!=-999)
{
temp->next=NULL;
if(first==NULL)
{
first=temp;
prev=first;
}
else
{
prev->next=temp;
prev=temp;
}
temp=(node *)(malloc(sizeof(node)));
scanf("%d",&temp->number);
} //end of while
}
void delete1(void)
{
int num;
printf(" Enter the number to delete ");
scanf("%d",&num);
if(first->number==num)
{
first=first->next;
return;
}
else
{
prev=first;
curr=first->next;
while(curr->next!=NULL)
{
if(curr->number==num)
{
prev->next=curr->next;
return;
}
prev=curr;
curr=curr->next;
}
}
if(curr->number==num)
{
prev->next=NULL;
return;
}
printf(" No such number");
}
void insertbefore(void)
{
int nu;
temp=(node *)(malloc(sizeof(node)));
printf(" Enter the number ");
scanf("%d",&temp->number);
printf(" Insert before which number ");
scanf("%d",&nu);
temp->next=NULL;
prev=first;
curr=first;
if(first==NULL) //if the list is empty then we can insert in this way
{
first=temp;
return;
}
if(curr->number==nu)
{
temp->next=first;
first=temp;
return;
}
else
{
prev=curr;
curr=curr->next;
while(curr->next!=NULL)
{
if(curr->number==nu)
{
prev->next=temp;
temp->next=curr;
return;
}
prev=curr;
curr=curr->next;
}
}
if(curr->number==nu)
{
prev->next=temp;
temp->next=curr;
return;
}
printf(" No such number ");
}
void insertafter(void)
{
int nu;
temp=(node *)(malloc(sizeof(node)));
printf(" Enter the number ");
scanf("%d",&temp->number);
printf(" Insert after which number ");
scanf("%d",&nu);
temp->next=NULL;
prev=first;
curr=first;
if(first==NULL) //if the list is empty then we can insert in this way
{
first=temp;
return;
}
if(curr->number==nu)
{
temp->next=curr->next;
curr->next=temp;
return;
}
else
{
prev=curr;
curr=curr->next;
while(curr->next!=NULL)
{
if(curr->number==nu)
{
temp->next=curr->next;
curr->next=temp;
return;
}
prev=curr;
curr=curr->next;
}
}
if(curr->number==nu)
{
curr->next=temp;
return;
}
printf(" No such number ");
}
void print(void)
{
printf(" The list is ");
printf(" ----------- ");
temp=first;
while(temp!=NULL)
{
printf("%d-->",temp->number);
temp=temp->next;
}
printf("Nil");
getch();
}
void main()
{
int ch=0;
first=NULL;
clrscr();
printf(" Linked List creation ");
create();
clrscr();
while(ch!=5)
{
clrscr();
printf(" 1.Insert Before");
printf(" 2.Insert After");
printf(" 3.Delete ");
printf(" 4.Print ");
printf(" 5.Exit ");
printf(" Enter your choice ");
scanf("%d",&ch);
switch(ch)
{
case 1:
insertbefore();
print();
break;
case 2:
insertafter();
print();
break;
case 3:
delete1();
print();
break;
case 4:
print();
break;
case 5:
print();
exit(1);
}
}
getch();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.