directory structure change, organize by class number as opposed to mod number
Signed-off-by: Amrit Panesar <apanesar@4195tech.com>
This commit is contained in:
1 parent
2a3d6fc042
commit
8683384387
480 files changed
+7
No files matched your search
@@ -0,0 +1,80 @@
|
||||
/******************************************************************************
|
||||
* Project: Project 2a *
|
||||
* Class Name: Project2a *
|
||||
* Author: Amrit Panesar -ASP ,o/ *
|
||||
* Last Edited: 08/15/2012 *
|
||||
* Hours: 0.25 Hours *
|
||||
* Purpose: To demonstrate the ability to create a conventionally named *
|
||||
* java application, use comments to document the software, *
|
||||
* use imported software components, instantiante objects, *
|
||||
* use methods associated with objects of prebuilt classes, *
|
||||
* use of user friendly prompts, echos, and error messages, *
|
||||
* use try and catch to prevent hard software crashes. *
|
||||
******************************************************************************/
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Project2a
|
||||
{
|
||||
public static void main(String[] args) // main
|
||||
{
|
||||
Scanner console = new Scanner(System.in); // direction 1
|
||||
/* begin direction 2 */
|
||||
int iWholeNum01 = 0;
|
||||
try
|
||||
{
|
||||
System.out.print("Please input a whole number: "); // user friendly prompt
|
||||
iWholeNum01 = console.nextInt(); // grab user input
|
||||
System.out.println("Your number was: " + iWholeNum01 +"\n"); // user friendly echo
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("\nWe're sorry, this was not a whole number.\n"+
|
||||
"Please re-run the program."); // (hopefully) user friendly error massage
|
||||
return; // end execution here. we want them to wisen up eh.
|
||||
}
|
||||
|
||||
/* begin direction 3 */
|
||||
double dRealNum01 = 0.0;
|
||||
try
|
||||
{
|
||||
System.out.print("Please input a decimal number: "); // user friendly prompt
|
||||
dRealNum01 = console.nextDouble(); // grab user input
|
||||
System.out.println("Your number was: " + dRealNum01 +"\n"); // user friendly echo
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("\nWe're sorry, this was not a real number.\n"+
|
||||
"Please re-run the program."); // (hopefully) user friendly error massage
|
||||
return; // end execution here. we want them to wisen up eh.
|
||||
}
|
||||
|
||||
/* begin direction 4 */
|
||||
String sFirstName = "";
|
||||
System.out.print("Please enter your First name: "); // user friendly prompt
|
||||
sFirstName = console.next(); // grab user input
|
||||
System.out.println("Your name is: " + sFirstName); // user friendly echo
|
||||
|
||||
// Done !
|
||||
}
|
||||
}
|
||||
|
||||
/* Output:
|
||||
|
||||
E:\programs\Mod1\Project2>java Project2a
|
||||
Please input a whole number: 50
|
||||
Your number was: 50
|
||||
|
||||
Please input a decimal number: 25.0
|
||||
Your number was: 25.0
|
||||
|
||||
Please enter your First name: Amrit Panesar
|
||||
Your name is: Amrit
|
||||
|
||||
E:\programs\Mod1\Project2>java Project2a
|
||||
Please input a whole number: error
|
||||
|
||||
We're sorry, this was not a whole number.
|
||||
Please re-run the program.
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,28 @@
|
||||
PROMPT for input of hours worked
|
||||
STORE hours worked
|
||||
CALCULATE gross pay
|
||||
grossPay = hours * rate
|
||||
CALCULATE tax
|
||||
Tax = gross * .14
|
||||
CALCULATE net pay
|
||||
netPay = gross – taxes
|
||||
CALCULATE clothing expense
|
||||
clothing = netPay * .10
|
||||
CALCULATE school supply expense
|
||||
supplies = netPay * .01
|
||||
CALCULATE remainder
|
||||
remainder = netPay – clothing – supplies
|
||||
CALCULATE student savings
|
||||
studentSavings = remainder * .25
|
||||
CALCULATE parental savings
|
||||
Parental savings = student Savings * .5
|
||||
DISPLAY pay rate
|
||||
DISPLAY hours
|
||||
DISPLAY gross pay
|
||||
DISPLAY taxes
|
||||
DISPLAY net pay
|
||||
DISPLAY clothing expense
|
||||
DISPLAY supply expense
|
||||
DISPLAY student savings
|
||||
DISPLAY parental savings
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
/******************************************************************************
|
||||
* Project: Project 2b *
|
||||
* Class Name: SummerJob *
|
||||
* Author: Amrit Panesar -ASP ,o/ *
|
||||
* Last Edited: 08/23/2012 *
|
||||
* Hours: 0.50 Hours *
|
||||
* Purpose: To calculate the gross and net pay of a hypothetical summer *
|
||||
* job. The ability to deduct taxes is also demonstrated. *
|
||||
******************************************************************************/
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SummerJob
|
||||
{
|
||||
public static void main(String[] args) // main
|
||||
{
|
||||
final double HOURLY_WAGE = 15.50;// hourly wage
|
||||
final double PARENT_RATE = 0.50; // 50 cents per every *whole* dollar made.
|
||||
final double TAX_RATE = 0.14; // 14% taxes withheld
|
||||
final double CLOTHING_RATE = 0.10; // 10% for clothing
|
||||
final double SCHOOL_RATE = 0.01; // 01% for school supplies
|
||||
final double SAVINGS_RATE = 0.25; // 25% for savings bond purchase
|
||||
double dHoursWorked = 0.0;
|
||||
|
||||
//PROMPT for input of hours worked
|
||||
try
|
||||
{
|
||||
Scanner console = new Scanner(System.in);
|
||||
System.out.print("Please enter the ammount of hours worked: ");
|
||||
//STORE hours worked
|
||||
dHoursWorked = console.nextDouble();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("We're sorry, that was an invalid value.\n"
|
||||
+ "Please re-run the program.");
|
||||
return;
|
||||
}
|
||||
//CALCULATE gross pay
|
||||
//grossPay = hours * rate
|
||||
double dGrossPay = (dHoursWorked * HOURLY_WAGE);
|
||||
//CALCULATE tax
|
||||
//Tax = gross * .14
|
||||
double dTaxes = (dGrossPay * TAX_RATE);
|
||||
//CALCULATE net pay
|
||||
//netPay = gross – taxes
|
||||
double dNetPay = (dGrossPay - dTaxes);
|
||||
//CALCULATE clothing expense
|
||||
//clothing = netPay * .10
|
||||
double dCloExp = (dNetPay * CLOTHING_RATE);
|
||||
//CALCULATE school supply expense
|
||||
//supplies = netPay * .01
|
||||
double dSchExp = (dNetPay * SCHOOL_RATE);
|
||||
//CALCULATE remainder
|
||||
//remainder = netPay – clothing – supplies
|
||||
double dEODBal = (dNetPay - dCloExp - dSchExp);
|
||||
//CALCULATE student savings
|
||||
//studentSavings = remainder * .25
|
||||
double dSavBon = (int)(dEODBal * SAVINGS_RATE);
|
||||
//CALCULATE parental savings
|
||||
//Parental savings = student Savings * .5
|
||||
double dParSav = (dSavBon * PARENT_RATE);
|
||||
double dGTotal = (dEODBal + dSavBon + dParSav);
|
||||
|
||||
// System.out.format("%.2f", 10.499);
|
||||
//DISPLAY pay rate
|
||||
System.out.format("Your pay rate is: $%.2f per hour\n", dHourlyWage); // pay rate
|
||||
//DISPLAY hours
|
||||
System.out.format("You worked: %.2f hours\n", dHoursWorked); // hours
|
||||
//DISPLAY gross pay
|
||||
System.out.format("Your taxable income is: $%.2f\n", dGrossPay); // gross pay
|
||||
//DISPLAY taxes
|
||||
System.out.format("Taxes taken from your paycheck: $%.2f\n",dTaxes); // taxes
|
||||
//DISPLAY net pay
|
||||
System.out.format("Earning you a total of: $%.2f\n", dNetPay); // net pay
|
||||
System.out.format("------------------------------------------------------\n");
|
||||
//DISPLAY clothing expense
|
||||
System.out.format("Your withholdings for clothes expenses are: $%.2f\n", dCloExp);
|
||||
//DISPLAY supply expense
|
||||
System.out.format("Your withholdings for school supplies are: $%.2f\n", dSchExp);
|
||||
//DISPLAY student savings
|
||||
System.out.format("Your withholdings for a saving bond are: $%.2f\n", dSavBon);
|
||||
System.out.format("------------------------------------------------------\n");
|
||||
//DISPLAY parental savings
|
||||
System.out.format("Your parental contributions for this month are: $%.2f\n", dParSav);
|
||||
System.out.format("Giving you a grand total of: %.2f\n", dGTotal);
|
||||
}
|
||||
}
|
||||
/* Output:
|
||||
E:\programs\Mod1\Project2>java SummerJob
|
||||
Please enter the ammount of hours worked: 10
|
||||
Your pay rate is: $15.50 per hour
|
||||
You worked: 10.00 hours
|
||||
Your taxable income is: $155.00
|
||||
Taxes taken from your paycheck: $21.70
|
||||
Earning you a total of: $133.30
|
||||
------------------------------------------------------
|
||||
Your withholdings for clothes expenses are: $13.33
|
||||
Your withholdings for school supplies are: $1.33
|
||||
Your withholdings for a saving bond are: $29.00
|
||||
------------------------------------------------------
|
||||
Your parental contributions for this month are: $14.50
|
||||
Giving you a grand total of: 162.14
|
||||
|
||||
E:\programs\Mod1\Project2>java SummerJob
|
||||
Please enter the ammount of hours worked: 20
|
||||
Your pay rate is: $15.50 per hour
|
||||
You worked: 20.00 hours
|
||||
Your taxable income is: $310.00
|
||||
Taxes taken from your paycheck: $43.40
|
||||
Earning you a total of: $266.60
|
||||
------------------------------------------------------
|
||||
Your withholdings for clothes expenses are: $26.66
|
||||
Your withholdings for school supplies are: $2.67
|
||||
Your withholdings for a saving bond are: $59.00
|
||||
------------------------------------------------------
|
||||
Your parental contributions for this month are: $29.50
|
||||
Giving you a grand total of: 325.77
|
||||
|
||||
E:\programs\Mod1\Project2>java SummerJob
|
||||
Please enter the ammount of hours worked: 40
|
||||
Your pay rate is: $15.50 per hour
|
||||
You worked: 40.00 hours
|
||||
Your taxable income is: $620.00
|
||||
Taxes taken from your paycheck: $86.80
|
||||
Earning you a total of: $533.20
|
||||
------------------------------------------------------
|
||||
Your withholdings for clothes expenses are: $53.32
|
||||
Your withholdings for school supplies are: $5.33
|
||||
Your withholdings for a saving bond are: $118.00
|
||||
------------------------------------------------------
|
||||
Your parental contributions for this month are: $59.00
|
||||
Giving you a grand total of: 651.55
|
||||
*/
|
||||
Binary file not shown.
Whitespace-only changes.
Reference in new issue
Block a user