PDA

View Full Version : Code Base



ManagerJosh
05-10-2007, 11:04 PM
First sets of code




/*
* ManagerJosh
* May 11, 2007
* Exercise E, Question 1
* Ref: a5a2b686f6ee54326756031935c2c8bc
*/



public class ageGrouping {

/* intermediate variable(s) */



/* output variable(s) */

private static int countOver30 = 0;
private static int countUnder30 = 0;


public static void main(String[] args)
{
/* input variables */

double ageJoe;
double ageSue;
double ageElvis;
double ageLac;
double ageSuman;
double ageEric;


double testValue;

/* set input variable values */

ageJoe = 17;
ageSue = 19;
ageElvis = 72;
ageLac = 44;
ageSuman = 30;
ageEric = 53;

testValue = 30;

/* run test */

countAge(ageJoe, testValue);
countAge(ageSue, testValue);
countAge(ageElvis, testValue);
countAge(ageLac, testValue);
countAge(ageSuman, testValue);
countAge(ageEric, testValue);

/* calculate and print output variable value(s) */

System.out.println("Over 30: " + countOver30);
System.out.println("Under 30: " + countUnder30);
}
public static void countAge(double age, double testValue)
{
if (age >= testValue)
{
++ countOver30;
}
else

{
++ countUnder30;
}
}

}

ManagerJosh
05-11-2007, 12:29 AM
/*
* ManagerJosh
* May 11, 2007
* Exercise E, Question 1
* Ref: a5a2b686f6ee54326756031935c2c8bc
*/

public class majorsCalPoly {

/* intermediate variable(s) */

/* output variable(s) */
private static int majorCountAG;
private static int majorCountCOM;
private static int majorCountTED;
private static int majorCountPHY;
private static int majorCountCHM;
private static int majorCountEGR;

public static void main(String[] args)
{
String majorAbigail = "AG";
String majorArron = "AG";
String majorAlan = "AG";
String majorAnh = "AG";
String majorJay = "COM";
String majorTimothy = "TED";
String majorPhonetrya = "PHY";
String majorChristy = "CHM";
String majorEiselle = "EGR";
String majorElenaor = "EGR";

String compareValue = "";

countMajors(majorAbigail, compareValue);
countMajors(majorArron, compareValue);
countMajors(majorAlan, compareValue);
countMajors(majorAnh, compareValue);
countMajors(majorJay, compareValue);
countMajors(majorTimothy, compareValue);
countMajors(majorPhonetrya, compareValue);
countMajors(majorChristy, compareValue);
countMajors(majorEiselle, compareValue);
countMajors(majorElenaor, compareValue);

/* calculate and print output variable value(s) */
System.out.println("AG Majors: " + majorCountAG);
System.out.println("COM Majors: " + majorCountCOM);
System.out.println("TED Majors: " + majorCountTED);
System.out.println("PHY Majors: " + majorCountPHY);
System.out.println("CHM Majors: " + majorCountCHM);
System.out.println("EGR Majors: " + majorCountEGR);
}

public static void countMajors(String major, String compareValue)
{
if (major == "AG")
{
++ majorCountAG;
}
if (major == "COM")
{
++ majorCountCOM;
}
if (major == "TED")
{
++ majorCountTED;
}
if (major == "PHY")
{
++ majorCountPHY;
}
if (major == "CHM")
{
++ majorCountCHM;
}
if (major == "EGR")
{
++ majorCountEGR;
}
}

}

ManagerJosh
05-11-2007, 12:36 AM
/*
* ManagerJosh
* May 11, 2007
* Exercise E, Question 1
* Ref: a5a2b686f6ee54326756031935c2c8bc
*/



public class majorsCalPoly {

/* intermediate variable(s) */


/* output variable(s) */

private static int majorCountAG;
private static int majorCountCOM;
private static int majorCountTED;
private static int majorCountPHY;
private static int majorCountCHM;
private static int majorCountEGR;

public static void main(String[] args)
{
String majorAbigail = "AG";
String majorArron = "AG";
String majorAlan = "AG";
String majorAnh = "AG";
String majorJay = "COM";
String majorTimothy = "TED";
String majorPhonetrya = "PHY";
String majorChristy = "CHM";
String majorEiselle = "EGR";
String majorElenaor = "EGR";

String compareValue = "";

countMajors(majorAbigail, compareValue);
countMajors(majorArron, compareValue);
countMajors(majorAlan, compareValue);
countMajors(majorAnh, compareValue);
countMajors(majorJay, compareValue);
countMajors(majorTimothy, compareValue);
countMajors(majorPhonetrya, compareValue);
countMajors(majorChristy, compareValue);
countMajors(majorEiselle, compareValue);
countMajors(majorElenaor, compareValue);

/* calculate and print output variable value(s) */

System.out.println("AG Majors: " + majorCountAG);
System.out.println("COM Majors: " + majorCountCOM);
System.out.println("TED Majors: " + majorCountTED);
System.out.println("PHY Majors: " + majorCountPHY);
System.out.println("CHM Majors: " + majorCountCHM);
System.out.println("EGR Majors: " + majorCountEGR);
}

public static void countMajors(String major, String compareValue)
{
if (major.compareTo("AG") == 0)
{
++ majorCountAG;
}
if (major.compareTo("COM") == 0)
{
++ majorCountCOM;
}
if (major.compareTo("TED") == 0)
{
++ majorCountTED;
}
if (major.compareTo("PHY") == 0)
{
++ majorCountPHY;
}
if (major.compareTo("CHM") == 0)
{
++ majorCountCHM;
}
if (major.compareTo("EGR") == 0)
{
++ majorCountEGR;
}

}

}