Software Development and Programming Careers (Official Discussion Thread)

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,298
Reputation
5,571
Daps
83,581
go to labs.codecademy.com and go to javascript

here is a sample solution in Javascript, but you will have to convert to Java and do the formatting on your own and add whatever else you need to meet the professor's specifications... but it should give you an idea of how to find the maximum sale of one particular employee and how to compare the maximum sale amongst two employees:
Code:
function employee(firstName, lastName, sales)
{
  this.firstName = firstName;
   this.lastName = lastName;
  this.name = firstName + " " + lastName;
   this.sales = sales;
   this.maxSales = [];
   this.getMaxSales = function(input)
   {
  var holder = 0;
  for(i=0; i<input.length; i++)
  {
  if(input[i] > holder)
  {
  holder = input[i];
  }
  }
  return(holder);
   };
}

function getEmployeeMaxSale()
{
  var salesholder = 0;
  var nameholder = "";
  for(i = 0; i < employeeArray.length; i++)
  {
  if(employeeArray[i].maxSales > salesholder)
  {
  salesholder = employeeArray[i].maxSales;
  nameholder = employeeArray[i].name;
  }
  
  
  }
  console.log("The employee with the maximum sale is: " + nameholder +
  " with a sale of " + salesholder + ".");
}


// 3 employees created with the Employee constructor
var employeea = new employee("Lewis", "Peters", [9,1,4,1]);
employeea.maxSales = employeea.getMaxSales(employeea.sales);

var employeeb = new employee("Steven", "Jones", [4,3,8,2]);
employeeb.maxSales = employeeb.getMaxSales(employeeb.sales);

var employeec = new employee("Adrian", "Rainwater", [4,10,3,5]);
employeec.maxSales = employeec.getMaxSales(employeec.sales);


// Output the Employee Data
console.log(employeea.name);
console.log("Sales: " + employeea.sales);
console.log(employeea.name + "'s maximum sale is: " + employeea.maxSales + "\n");

console.log(employeeb.name);
console.log("Sales: " + employeeb.sales);
console.log(employeeb.name + "'s maximum sale is: " + employeeb.maxSales + "\n");

console.log(employeec.name);
console.log("Sales: " + employeec.sales);
console.log(employeec.name + "'s maximum sale is: " + employeec.maxSales + "\n");


// An Array that holds all the employees. Used to get the max sale of all employees
var employeeArray = [employeea, employeeb, employeec];

// Calls the function to get the max sale of all the employees
getEmployeeMaxSale();
 

HabitualLineSteppa

....Fuh Q.
Joined
May 1, 2012
Messages
2,634
Reputation
1,200
Daps
9,597
go to labs.codecademy.com and go to javascript

here is a sample solution in Javascript, but you will have to convert to Java and do the formatting on your own and add whatever else you need to meet the professor's specifications... but it should give you an idea of how to find the maximum sale of one particular employee and how to compare the maximum sale amongst two employees:
Code:
function employee(firstName, lastName, sales)
{
  this.firstName = firstName;
   this.lastName = lastName;
  this.name = firstName + " " + lastName;
   this.sales = sales;
   this.maxSales = [];
   this.getMaxSales = function(input)
   {
  var holder = 0;
  for(i=0; i<input.length; i++)
  {
  if(input[i] > holder)
  {
  holder = input[i];
  }
  }
  return(holder);
   };
}

function getEmployeeMaxSale()
{
  var salesholder = 0;
  var nameholder = "";
  for(i = 0; i < employeeArray.length; i++)
  {
  if(employeeArray[i].maxSales > salesholder)
  {
  salesholder = employeeArray[i].maxSales;
  nameholder = employeeArray[i].name;
  }
 
 
  }
  console.log("The employee with the maximum sale is: " + nameholder +
  " with a sale of " + salesholder + ".");
}


// 3 employees created with the Employee constructor
var employeea = new employee("Lewis", "Peters", [9,1,4,1]);
employeea.maxSales = employeea.getMaxSales(employeea.sales);

var employeeb = new employee("Steven", "Jones", [4,3,8,2]);
employeeb.maxSales = employeeb.getMaxSales(employeeb.sales);

var employeec = new employee("Adrian", "Rainwater", [4,10,3,5]);
employeec.maxSales = employeec.getMaxSales(employeec.sales);


// Output the Employee Data
console.log(employeea.name);
console.log("Sales: " + employeea.sales);
console.log(employeea.name + "'s maximum sale is: " + employeea.maxSales + "\n");

console.log(employeeb.name);
console.log("Sales: " + employeeb.sales);
console.log(employeeb.name + "'s maximum sale is: " + employeeb.maxSales + "\n");

console.log(employeec.name);
console.log("Sales: " + employeec.sales);
console.log(employeec.name + "'s maximum sale is: " + employeec.maxSales + "\n");


// An Array that holds all the employees. Used to get the max sale of all employees
var employeeArray = [employeea, employeeb, employeec];

// Calls the function to get the max sale of all the employees
getEmployeeMaxSale();
:to:

Thank you breh...Just thanks!

Pos rep + dap
 

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,298
Reputation
5,571
Daps
83,581
I've been working on this solution for a while. It is actually much better than the last since it allows you to manually enter a new employee. Copy the code and paste it into the codecademy javascript console at: http://labs.codecademy.com/. Let me know if you have any questions about what is going on in any portions of the program. I'll leave it up to you on how to implement this in Java. This solution doesn't solve everything you've been asking for, but I'll leave that up to you. It shouldn't be all that difficult to implement the rest...
Code:
// This is the array all new employees will be stored in
var employeeArray = [];

// Function to create new Employees
function createEmployee()
{
  var firstName = prompt("What is the employee's first name?");
  var lastName = prompt("What is the employee's last name?");
  var processSales = prompt("List the sales, separated by a comma").split(",");
  var sales = [];
 
  //Converts sales into an array with numbers
  for(i=0; i<processSales.length; i++)
  {
     sales[i] = processSales[i].trim();
     sales[i] = parseInt(sales[i]);
   }
 

   // Employee Constructor
  function employee(firstName, lastName, sales)
  {
  this.firstName = firstName;
  this.lastName = lastName;
  this.name = firstName + " " + lastName;
  this.sales = sales;
    this.maxSales = '';
    this.getMaxSales = function(input)
    {
  var holder = 0;
  for(i=0; i<input.length; i++)
  {
  if(input[i] > holder)
  {
  holder = input[i];
  }
  }
  return(holder);
    };
  }
 
  // Push new employee objects into the employeeArray array
  var newemp = new employee(firstName, lastName, sales);

  newemp.maxSales = newemp.getMaxSales(newemp.sales);
  employeeArray.push(newemp);
}


// Finds the employee with the highest sales
function getEmployeeMaxSale()
{
  var salesholder = 0;
  var nameholder = "";
  for(i = 0; i < employeeArray.length; i++)
  {
  if(employeeArray[i].maxSales > salesholder)
  {
  salesholder = employeeArray[i].maxSales;
  nameholder = employeeArray[i].name;
  } 
  }
  alert("The employee with the maximum sale is: " + nameholder +
  " with a sale of " + salesholder + ".");
}

var programStart = 0;


// Lists all of the employee's index number and name
function listEmployees()
{
  for(i=0; i<employeeArray.length; i++)
  {
  alert("Guest index: " + [i] + "\n Employee Name: " + employeeArray[i].name + "\n Sales: " + employeeArray[i].sales + "\n Max Sale: " + employeeArray[i].maxSales);
  }
}
// Start the program loop
while(programStart!=-1)
{
   var getChoice = prompt("What would you like to do? Input 1 to add an employee, 2 to get Max Sales, 3 to list employees, or 4 to quit.");
  var userChoice = parseInt(getChoice);
 
   if(userChoice === 4)
   {
     programStart = -1;
   }
 
   else if(userChoice === 1)
   {
     createEmployee();
   }
 
   else if(userChoice === 2)
   {
     getEmployeeMaxSale();
   }
 
  else if(userChoice === 3)
  {
  listEmployees();
  }
 
   else
   {
     alert("That is not a valid choice!");
   }
}
 
Last edited:

Spin

All Star
Joined
Jul 11, 2012
Messages
1,010
Reputation
390
Daps
2,862
Are they expecting to make you do this with a GUI?
I'm just getting in to python but something keeps irking me to give ruby another look. The reason I'm going for python is because I see too many of these coding schools focusing on ruby. Python also has a larger community and the syntax seems easier. Any tips?

Was at a meetup tonight and found out MongoDB offers free courses on their database technology. I see Mongo popping up on job boards as the NoSQL database of choice. Right now they're offering a intro class using Python. They do one with JavaScript and other languages from time to time as well. The videos seem to go over everything so the language shouldn't actually matter too much.

You do get a certificate

MongoDB University
 

Type Username Here

Not a new member
Joined
Apr 30, 2012
Messages
16,368
Reputation
2,385
Daps
32,641
Reppin
humans
Was at a meetup tonight and found out MongoDB offers free courses on their database technology. I see Mongo popping up on job boards as the NoSQL database of choice. Right now they're offering a intro class using Python. They do one with JavaScript and other languages from time to time as well. The videos seem to go over everything so the language shouldn't actually matter too much.

You do get a certificate

MongoDB University


Wow, thanks. I was looking to start fukking with this.
 

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,298
Reputation
5,571
Daps
83,581
Having a blast with this Javascript. i can't wait to get PHP sufficiently under my belt as well. i'll post a few things I've been messing around with soon.
 

Black Hans

Follow Jesus. Be Beautiful
Supporter
Joined
May 8, 2012
Messages
7,499
Reputation
-1,226
Daps
18,644
Reppin
John 14:6
What are some good languages to learn? I plan on starting my associates in Information systems and I have the option of learning SQL(mandatory) and 2 other languages. The choices are java , JavaScript, php, c++, perl, and Visual Basic. I'm not interested in game programming. More leaning towards software and web development.

Things are leaning more towards web/mobile development so I would recommend taking Java and Visual Basic if VB is the .NET version. As for languages you should learn in general, here's a list

  • C#
  • HTML5
  • CSS3
  • Javascript
  • JQuery
  • ASP.NET
  • ASP.NET MVC
  • Java
  • SQL
If you can showing professional level understand in at least four of the languages I listed, you should be fine.
 

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,298
Reputation
5,571
Daps
83,581
I've been doing a ton of reading on the DOM. It's not the prettiest interface, but given a month or so, I'll have a thorough understanding of it. I've been very tempted to take some time to learn PHP, but I think I'll stay on the Javascript path and focus on Node.js for the server-side.

Something interesting from Douglas Crockford, who is a key figure in the Javascript community, is he talks about how he now focuses on simplicity and using as little of a language as he can as opposed to how he was when he was younger, where he'd try to use as many aspects of a language as possible. I think simplicity is an admirable path since it makes others reading your code easier and it makes it easier for you to remember down the line what you were doing.

Why I find this important is that as I've been learning, I've been trying to memorize any and everything, which ultimately will not be possible. You don't have to know every word in a dictionary to be able to write intelligently... so while it might be nice that you have an overview of all the various aspects of a language, it's not necessary that you remember and master every single aspect... only the essentials.
 

keepemup

Banned
Joined
Jun 9, 2012
Messages
4,743
Reputation
-982
Daps
5,349
I've been doing a ton of reading on the DOM. It's not the prettiest interface, but given a month or so, I'll have a thorough understanding of it. I've been very tempted to take some time to learn PHP, but I think I'll stay on the Javascript path and focus on Node.js for the server-side.

Something interesting from Douglas Crockford, who is a key figure in the Javascript community, is he talks about how he now focuses on simplicity and using as little of a language as he can as opposed to how he was when he was younger, where he'd try to use as many aspects of a language as possible. I think simplicity is an admirable path since it makes others reading your code easier and it makes it easier for you to remember down the line what you were doing.

Why I find this important is that as I've been learning, I've been trying to memorize any and everything, which ultimately will not be possible. You don't have to know every word in a dictionary to be able to write intelligently... so while it might be nice that you have an overview of all the various aspects of a language, it's not necessary that you remember and master every single aspect... only the essentials.
You seem like an intrepid young man and I want to commend you on your helpful words and the help you have provided others.

Your last point has brought something to my attention that I recently discovered that I would like to share with you. It's a book by Adler and Mortimer entitled "How to Read a Book" (If you've heard of it/read it then disregard the following). It's simple yet absolutely profound. I believe, in a way, we already have an understanding of what it takes to be able to read something and comprehend it thoroughly with the ability to recall the salient points, yet this author has elucidated it in a way that allows one to follow along easily and implement the methods prescribed.

It may be of help for you trying to learn a programming language - it has been for me.
 

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,298
Reputation
5,571
Daps
83,581
Have you made anything useful in it though? The best way to learn is to make something :ufdup:

Actually I have. It was nothing complex, but quite useful all the same... However, the past few months have been spent more on learning the language in-depth as opposed to making functional stuff. Right now, I'm in the 'make useful stuff phase,' since I've garnered a fairly thorough understanding of the language.

A lot of people dislike Javascript because although it looks like a C-styled language, it's more of a functional language and has several quirks that can be maddening if you don't know about them, and you would never know about them if you didn't read about them. It is a bad language to try to learn by reading other people's source codes without first learning from more formal sources, such as books, because of aforementioned quirks.

Here is a simple example. Do you know why the first example works and why the second doesn't?

Example 1:
Code:
test();

function test()
{
console.log("Hi");
}

Example 2:
test();

var test = function()
{
console.log("hi");
}

This has to do with 'hoisting', meaning the declaration of a variable is hoisted to the top of a scope, but not the initialization. On the other hand, all of a function declaration is hoisted... What this means is that if you refer to a variable before it is declared and initialized, the declaration will be recognized, but it's initialization won't be.

Example
Code:
console.log(i);   //outputs undefined
var i = 5;

This code works, but the output will be 'undefined' instead of giving you an error stating that i doesn't exist. The variable is recognized as being declared, but, it's initial value isn't recognized until you actually come across the var i = 5 line;

The interpreter looks at that line as:
var i;
console.log(i);
i = 5;

That is why the latter code in the initial example doesn't work. It is an anonymous function stored as a variable as opposed to a variable declaration, so it works under the same principle.

It is interpreted as:
var test;
test();
test = function() {console.log("hi")};


On the other hand, the first code snippet gets interpreted as:
function test() {console.log("hi");
test();

Here is a more common one though that can have very bad results if you don't know what's going on, such as:

Code:
function test()
{
   var a = 5;
}   
console.log(a);     //outputs undefined

Code:
function test()
{
   a = 5;
}

console.log(a)    //outputs 5

Javascript has function scope, but if you don't declare your variables you intend to use exclusively in a function, you end up creating a global variable as in the latter example. So Javascript is one language that it pays to learn inside and out before you start using it in any serious fashion.
 

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,298
Reputation
5,571
Daps
83,581
You seem like an intrepid young man and I want to commend you on your helpful words and the help you have provided others.

Your last point has brought something to my attention that I recently discovered that I would like to share with you. It's a book by Adler and Mortimer entitled "How to Read a Book" (If you've heard of it/read it then disregard the following). It's simple yet absolutely profound. I believe, in a way, we already have an understanding of what it takes to be able to read something and comprehend it thoroughly with the ability to recall the salient points, yet this author has elucidated it in a way that allows one to follow along easily and implement the methods prescribed.

It may be of help for you trying to learn a programming language - it has been for me.

Thanks for the recommendation. I'll have to put it on my list of books to read. I'm always interested in the best ways to sort through information to get the essentials, because there is just so much information these days that you can waste a ton of time on frivolous things.
 
Top