[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Can anyone here help with part of this assignment for Java? It

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 33
Thread images: 3

Can anyone here help with part of this assignment for Java? It mostly deals with multi-dimensional arrays and inputting information into them.
>>
>>59815155
I did this last year. Still have the file on my computer. What do you need?
>>
>>59815190
Well I'm not entirely sure where to begin. I'm trying to create the array that takes a string for the name and a salary for the int so that I can add employees.
>>
>>59815220
Classes
>>
How long do you get to write this? It looks like it should take about 40 minutes I'd say.
>>
>>59815326
Well it's due tomorrow morning at 7 EST.
>>
These are just a few rules about the assignment as well.
>>
>>59815338
But how long have you had to not write it?
>>
>>59815220
Adopt the UNIX philosophy for this approach.

For each method, have each method only do one thing and do that one thing correctly. If you find that you need to do something else, make a new method.

Only work on one method at a time. If you are calling a method inside another method, just call it as if it's already coded, even if it doesn't exist yet.

Work from the ground up. This is the "divide and conquer" approach. I think you'll find that this project, and every other assignment, is a lot easier when you focus on one method at a time and pretend like all the other methods already exist, even if they don't.
>>
>>59815392
About a week. I was pretty busy with some other classes. I probably could have done it earlier but I just procrastinated too much.
>>
>>59815420
I've been there.

Post the entire project description and I can help you.

If this thread gets deleted, post it again on /wsr/ - work safe request
>>
pajeets helping pajeets
amazing
>>
File: 6dda07c222f727d382ac45bc460cd31d.png (150KB, 1904x704px) Image search: [Google]
6dda07c222f727d382ac45bc460cd31d.png
150KB, 1904x704px
>>59815550
This is the driver.

import java.util.Scanner;

public class Driver
{
public static void main (String[] args)
{
Scanner in = new Scanner(System.in);

Database db = new Database();

int choice = 0;

System.out.println("Employee Management System");

while (choice != 7)
{
//menu options
System.out.println("1. Add Employee.");
System.out.println("2. Remove Employee.");
System.out.println("3. Print Alphabetically.");
System.out.println("4. Print By ID Number.");
System.out.println("5. Issue Pay Increase.");
System.out.println("6. Get Payroll Cost.");
System.out.println("7. Quit.");

System.out.print("\nPlease enter your choice > ");
choice = in.nextInt();
in.nextLine();
>>
>>59815623
switch (choice)
{
case 1:
System.out.print(" Name? > ");
String name = in.nextLine();
System.out.print(" Salary? > ");
double salary = in.nextDouble();
in.nextLine();
db.addEmployee(name, salary);
break;
case 2:
System.out.print(" ID Number? > ");
int id = in.nextInt();
in.nextLine();
db.removeEmployee(id);
break;
case 3:
db.printAlphabetically();
break;
case 4:
db.printById();
break;
case 5:
System.out.print(" Percent Increase (e.g. .02)? > ");
double percent = in.nextDouble();
in.nextLine();
db.payIncrease(percent);
break;
case 6:
System.out.println(db.getPayrollCost());
break;
case 7:
break;
default:
System.out.println("That is an invalid choice. Please try again.\n");
}
System.out.println();
}
}
}
>>
>>59815550
And thanks for the help. I really appreciate it.
>>
>>59815623
hey man, the best way to start is by creating a class called Employee. Then think about what an Employee is. The Employee should have a name, and ID number, and a salary.

ID Number, in my opinion and for the sake of simplicity, could just be a global variable.

So, for the first method, we have:

  void addEmployee(String newName, int newSalary)
{
Employee newEmployee = new Employee();

newEmployee.name = newName;
newEmployee.salary = newSalary;

/*Assuming globalID is a global variable equal to 0
* at the start of the program */
Employee.idNumber = globalID;

/* Also have a global Employee[] employeeArray to
* store each Employee. */
employeeArray[globalID] = newEmployee;

/* Update the globalID counter */
globalID++;
}
>>
>>59815155
you probably should have started on it earlier
>>
>>59815817
Yeah but I could tackle this easily in an hour. He should be fine if he can wrap his mind around the concept of the Employee object and classes in general
>>
>>59815805
also, if you don't want to use global variables, you can use getter/setter methods.
>>
>>59815640
use code tags
>>
>>59815817
Yeah I definitely should have.

>>59815837
Thanks though, I think I should be able to get the concept.
>>
>>59815861
How do I use code tags?
>>
To remove an employee, you can do something like this (it's been a while since I used Java but I'm sure you can get the basic idea):

  void removeEmployee(int idNumber)
{
if(employeeArray[idNumber] == NULL)
{
System.out.println("Employee does not exist.");
}
else
{
employeeArray[idNumber] == NULL;
}
}
>>
>>59815613
And shitting up /g/ while doing it.

We need a pajeet containment board.
>>
>>59816039
It is only one thread though lol
>>
For printing alphabetically, I highly recommend you google "java bubble sort." It's very helpful for what you're trying to do. Good luck.
>>
>>59815949
>Not using Google styleguide
>>
RANGE BAN INDIA ALREADY
BAN ASSIGNMENT THREADS
>>
Ah, finally i understand. /g/ is for Homeworg!
>>
>>59816272
I honestly wasn't sure where else to post. It was mostly just a shot in the dark.
>>
>>59815155
For stuff like that check out our dedicated Homework board >>>/hm/
>>
>>59816294
I'll make sure to do that next time. Thanks!
>>
>>59815805
no but this would be too easy, the assignment says "its not easy"

it can't be that dumb
Thread posts: 33
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.