Programming Project Document - Itss 3211 2
Programming Project Document - Itss 3211 2
Design:
First I had to design to import a scanner and then I began to add the variables that
would be needed to perform the proper calculations when calculating the taxes
(taxableIncome and owedTaxes) and when using the switch statement (status). After
that I had to get the program to ask for inputs from the user to assign as values to
the necessary variables. The user would be prompted to enter their filling status as
0,1,2, or 3 (The parameters for the project said that 0 means filling as single, 1
means married filling jointly, 2 means married filling separately, and 3 means head
of household) in addition to their income level. In order to perform the calculations
properly it would require multiple if else statements and the proper logical
operations to perform the tax calculations properly. The program would display the
Taxes owed by displaying the value of the variable owedTaxes.
Coding:
///////////////////////////////////////
////////////////////////////////////////
//
ALL STUDENTS COMPLETE THESE SECTIONS
// Title:
TaxProject
// Files:
java.util.Scanner
// Semester:
//Fall 2015
//
// Author:
Adam Melaku
//Email:
Aam131630
// CS Login:
Aam131630
// Lecturer's Name: Professor Sohaee
// Course Section:
001
//
//////////////////// STUDENTS WHO GET HELP FROM OTHER THAN THEIR
PARTNER //////
//
fully acknowledge and credit all sources of help,
//
other than Instructors and TAs.
//
// Persons:
None.
//
// Online sources:
None.
//////////////////////////// 80 columns
wide //////////////////////////////////
import java.util.Scanner;
//Calculates the amount in taxes owed by filing status and income level.
//Bugs: None
//@Adam Melaku
public class TaxProject {
// A scanner needs to be created and the user will be asked to enter
their filling status.
// 0 for single, 1 for married filling jointly, 2 for married filling
separately and 3 for head of household.
// The user will later enter their income level.
// Switch statement will be used to determine designation for filling
status and then perform appropriate calculations to determine take owed.
// The calculated tax owed will be displayed at the end of the program
(taking into consideration the users filling status and income level).
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int status;
double taxableIncome;
double owedTaxes;
//declare variables
status = input.nextInt();
filling separately and 3 for head of household.
// 2 for married
//prompts user to
switch(status%4){
//switch
statement decides what filling status is and performs appropriate calculation
case 0:
//to output
appropriate statement.
if (taxableIncome <= 8350){
owedTaxes = taxableIncome*.1;
System.out.println("Tax is " + owedTaxes);}
else
if (taxableIncome <= 33950){
owedTaxes = ((taxableIncome-8350)*.15) +
(8350*.1);
System.out.println("Tax is " + owedTaxes);}
else
if (taxableIncome <= 82250){
owedTaxes = ((taxableIncome-33950)*.25) +
(8350*.1) + (25600*.15);
System.out.println("Tax is " + owedTaxes);}
else
if (taxableIncome <= 171550){
owedTaxes = ((taxableIncome82250)*.28) +(8350*.1) + (25600*.15) + (48300*.25);
System.out.println("Tax is " + owedTaxes);}
else
if (taxableIncome <= 372950){
owedTaxes = ((taxableIncome171550)*.33) + (8350*.1) + (25600*.15) + (48300*.25) + (89300*.28);
System.out.println("Tax is "+ owedTaxes);}
else{
owedTaxes = ((taxableIncome372950)*.35) + (8350*.1) + (25600*.15) + (48300*.25) + (89300*.28) +
(201400*.33);
System.out.println("Tax is "+ owedTaxes);}
break;
case 1:
if (taxableIncome <= 16700){
owedTaxes = taxableIncome*.1;
System.out.println("Tax is " + owedTaxes);}
else
if (taxableIncome <= 67900){
owedTaxes = ((taxableIncome-16700)*.15) +
(16700*.1);
System.out.println("Tax is " + owedTaxes);}
else
if (taxableIncome <= 137050){
owedTaxes = ((taxableIncome-67900)*.25) +
(16700*.1) + (51200*.15);
System.out.println("Tax is " + owedTaxes);}
else
if (taxableIncome <= 208850){
Testing:
I compiled the program and overall it worked great on my first try but there was
some debugging that needed to be done. I needed to readjust my quotes on my
system.out.prtinln lines so when it outputted the tax owed it wouldnt show up
mashed together. (I.e. Tax is 1940 instead of Tax is1940). In addition, I did a
small mathematical error in case 2 (human error) that I was able to troubleshoot
after a few minutes of attention. Overall, the program performed the calculations
properly and after I finished debugging it, I got the same answers the sample for our
project got and was satisfied with my work.