Please help me edit my code so it looks a little different but produces the same
ID: 3856602 • Letter: P
Question
Please help me edit my code so it looks a little different but produces the same output. Me and classmate did the assignment correctly but are afraid of plagarism.
Here is my code.
/**
* @(#)
* @author
* @version 1.00 6/25/2017 3:00 PM
* Program Purpose: Code a program that computes sales revenue
* to-date to determine the status of the company’s
* sales revenue and whether a year end bonus is in store for the employees.
*/
import java.util.*;
public class
{
public static void main(String[]args)
{
Calendar dateTime = Calendar.getInstance();//Get from Calender
Scanner input = new Scanner(System.in);//input Scanner
String monthNo = "";
String report = "TANDEM ENTERPRISES";
double salesRevenue = 0.0;
double quarterlySales = 0.0;
double annualSales = 0.0;
double projectedSales = 0.0;
double profitMargin = 0.0;
int monthCounter = 1;
int qrtrCounter = 1;
int noOfQtrs = 0;
int noOfMonths = 3;
String qrtrNo = "";
System.out.printf("%nWhat is the projected annual sales?");//Prompt for projected sales.
projectedSales = input.nextInt();
projectedSales = projectedSales/4;
System.out.printf("%nEnter the number of quarters (no less than 1 or greater than 4): ");//Prompt for qrtr
noOfQtrs = input.nextInt();
report += String.format("%nSALES REVENUE FOR %d QUARTER(S) OF %tY%n"
,noOfQtrs, dateTime);
do
{
quarterlySales = 0;
monthCounter = 1;
System.out.println();
for(monthCounter = 1; monthCounter<=noOfMonths; monthCounter++)
{
if(monthCounter == 1)
{
monthNo = "1st";
}//End if 1st month
else if(monthCounter == 2)
{
monthNo = "2nd";
}//End if 2nd month
else if(monthCounter == 3)
{
monthNo = "3rd";
}//End if 3rd month
System.out.printf("%nEnter the sales revenue for the %s month of quarter %d: ", monthNo, qrtrCounter);
salesRevenue = input.nextDouble();
quarterlySales = quarterlySales + salesRevenue;
}//END FOR LOOP
switch(qrtrCounter)
{
case 1:
qrtrNo = "1st";
break;
case 2:
qrtrNo = "2nd";
break;
case 3:
qrtrNo = "3rd";
break;
case 4:
qrtrNo = "4th";
break;
}//End switch statement
if (qrtrNo == "1st")
report += String.format("%n%s Quarter Sales: $%,19.2f", qrtrNo, quarterlySales);//when its 1st quarter
else
report += String.format("%n%s Quarter Sales: $%,20.2f", qrtrNo, quarterlySales);
annualSales += quarterlySales;
qrtrCounter ++;
}while(qrtrCounter<=noOfQtrs);//End DO WHILE
report += String.format("%n%nTotal Year-To-Date: $%,19.2f%n", annualSales);
System.out.printf("%s", report);
profitMargin = (annualSales/projectedSales * noOfQtrs) * 100;
if(noOfQtrs<4)
{
if(profitMargin>=20)
System.out.printf("%nKeep up the GOOD work and a possible year-end bonus!");
else
System.out.printf("%nSo far sales are lagging behind projections");
}//END IF noOfQrtrs<4
else
{
if(profitMargin>=20)
System.out.printf("%nIts been a GOOD year. Thank you for all your hard work!%n" +
"%nEmployees qualify for a 5%% year-end bonus!!!");
}//End IF profitMargin>=20
//System.exit(50);
}//End MAIN
}//END CLASS
And this is what the output should be
****OUTPUT***
/**TANDEM ENTERPRISES
SALES REVENUE FOR 1 QUARTER(S) OF 2017
1st Quarter Sales: $ 250,000.00
Total Year-To-Date: $ 250,000.00
Keep up the GOOD work and a possible year-end bonus!
TANDEM ENTERPRISES
SALES REVENUE FOR 1 QUARTER(S) OF 2017
1st Quarter Sales: $ 16,000.00
Total Year-To-Date: $ 16,000.00
So far sales are lagging behind projections>
TANDEM ENTERPRISES
SALES REVENUE FOR 4 QUARTER(S) OF 2017
1st Quarter Sales: $ 126,000.00
2nd Quarter Sales: $ 126,000.00
3rd Quarter Sales: $ 126,000.00
4th Quarter Sales: $ 126,000.00
Total Year-To-Date: $ 504,000.00
Its been a GOOD year. Thank you for all your hard work!
Employees qualify for a 5% year-end bonus!!!>
*/
Explanation / Answer
Hi I have changed alot of things in your program. Even the structure also, Its giving same output. But I have not changed textual information, as you asked for the same output. You can change question text also if you want. Below is your program: -
/**
* @(#)
* @author
* @version 1.00 6/25/2017 3:00 PM
* Purpose: Code a program that computes sales revenue
* to-date to determine the status of the company’s
* sales revenue and whether a year end bonus is in store for the employees.
*/
import java.util.*;
public class Assign1 {
private static double profMargin = 0.0;
private static double annSales = 0.0;
private static double projSales = 0.0;
private static int noOfQtrs = 0;
public static int getProjSales(Scanner keyboard) {
System.out.printf("%nWhat is the projected annual sales?");// Prompt for
// projected
// sales.
return keyboard.nextInt();
}
public static int getNoOfQuarters(Scanner keyboard) {
System.out.printf("%nEnter the number of quarters (no less than 1 or greater than 4): ");// Prompt
// for
// qrtr
return keyboard.nextInt();
}
public static double getSalesRev(Scanner keyboard, String monNo, int qrtrCount) {
System.out.printf("%nEnter the sales revenue for the %s month of quarter %d: ", monNo, qrtrCount);
return keyboard.nextDouble();
}
public static String createReport() {
Calendar dateNow = Calendar.getInstance();// Get from Calender
String rep = "TANDEM ENTERPRISES";
double salesRevenue = 0.0;
double quarterSal = 0.0;
String monNo = "";
int monCount = 1;
int qrtrCount = 1;
int noOfMonths = 3;
String qrtrNo = "";
Scanner keyboard = new Scanner(System.in);// keyboard Scanner
projSales = getProjSales(keyboard);
projSales = projSales / 4;
noOfQtrs = getNoOfQuarters(keyboard);
rep += String.format("%nSALES REVENUE FOR %d QUARTER(S) OF %tY%n", noOfQtrs, dateNow);
do {
quarterSal = 0;
monCount = 1;
System.out.println();
for (monCount = 1; monCount <= noOfMonths; monCount++) {
if (monCount == 1) {
monNo = "1st";
} // End if 1st month
else if (monCount == 2) {
monNo = "2nd";
} // End if 2nd month
else if (monCount == 3) {
monNo = "3rd";
} // End if 3rd month
salesRevenue = getSalesRev(keyboard, monNo, qrtrCount);
quarterSal = quarterSal + salesRevenue;
} // END FOR LOOP
switch (qrtrCount) {
case 1:
qrtrNo = "1st";
break;
case 2:
qrtrNo = "2nd";
break;
case 3:
qrtrNo = "3rd";
break;
case 4:
qrtrNo = "4th";
break;
}// End switch statement
if (qrtrNo == "1st")
rep += String.format("%n%s Quarter Sales: $%,19.2f", qrtrNo, quarterSal);// 1st quarter
else
rep += String.format("%n%s Quarter Sales: $%,20.2f", qrtrNo, quarterSal);
annSales += quarterSal;
qrtrCount++;
} while (qrtrCount <= noOfQtrs);// End DO WHILE
rep += String.format("%n%nTotal Year-To-Date: $%,19.2f%n", annSales);
return rep;
}
public static void main(String[] args) {
String fullReport = createReport();
System.out.printf("%s", fullReport);
profMargin = (annSales / projSales * noOfQtrs) * 100;
if (noOfQtrs < 4) {
if (profMargin >= 20)
System.out.printf("%nKeep up the GOOD work and a possible year-end bonus!");
else
System.out.printf("%nSo far sales are lagging behind projections");
} // END IF noOfQrtrs<4
else {
if (profMargin >= 20)
System.out.printf("%nIts been a GOOD year. Thank you for all your hard work!%n"
+ "%nEmployees qualify for a 5%% year-end bonus!!!");
} // End IF profMargin>=20
}// End MAIN
}// END CLASS
Sample Output: -
What is the projected annual sales?504000
Enter the number of quarters (no less than 1 or greater than 4): 4
Enter the sales revenue for the 1st month of quarter 1: 25000
Enter the sales revenue for the 2nd month of quarter 1: 1000000
Enter the sales revenue for the 3rd month of quarter 1: 240000
Enter the sales revenue for the 1st month of quarter 2: 23330
Enter the sales revenue for the 2nd month of quarter 2: 23420
Enter the sales revenue for the 3rd month of quarter 2: 33402
Enter the sales revenue for the 1st month of quarter 3: 30430
Enter the sales revenue for the 2nd month of quarter 3: 344022
Enter the sales revenue for the 3rd month of quarter 3: 343023
Enter the sales revenue for the 1st month of quarter 4: 340343
Enter the sales revenue for the 2nd month of quarter 4: 32323
Enter the sales revenue for the 3rd month of quarter 4: 32323
TANDEM ENTERPRISES
SALES REVENUE FOR 4 QUARTER(S) OF 2017
1st Quarter Sales: $ 1,265,000.00
2nd Quarter Sales: $ 80,152.00
3rd Quarter Sales: $ 717,475.00
4th Quarter Sales: $ 404,989.00
Total Year-To-Date: $ 2,467,616.00
Its been a GOOD year. Thank you for all your hard work!
Employees qualify for a 5% year-end bonus!!!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.