3 Replies - 2393 Views - Last Post: 01 March 2010 - 03:53 PM Rate Topic: -----

#1 idle_09  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 48
  • Joined: 02-March 08

Saleperson's Earnings

Post icon  Posted 01 October 2009 - 09:27 PM

1) Write a Java Application that prompts the user to enter the value of items sold, then displays the count of the items, total amount of the items, the salesperson's commission that is 9% of the total amount, and the salesperson's earnings that are $200 plus commission. There is no limit to the number of items sold by the salesperson.

2) Any items with value more than $350.00 are considered as high profitable. The company will pay $20 bonus for each high profitable item in addition to the sales commission. Modify your program to add bonus. For example, the same input values as listed in the book will yield the output:



//Ravi Shah
//Assignment 4
//Sales.java
//10/01/09

import java.util.Scanner;// program uses class Scanner

public class Sales
{
	public static void main(String[] args) 
	{
		new Sales ();
		Scanner input = new Scanner( System.in );
		
		double total; // sum of values
		double Commission; // Commission earned
		double earnings;// number with decimal point for average
		
		total = 0; // initialize total
		int valueCounter = 0; // initialize loop counter
		
		System.out.print( "Enter item Value, or -1 to quit: " ); 
		double value = input.nextDouble();
		
	 // loop until sentinel value read from user
		  while ( value != -1 ) 
		  {
			 total = total + value; // add value to total
			 valueCounter = valueCounter + 1; // increment counter

			 // prompt for input and read next value from user
			 System.out.print( "Enter item Value, or -1 to quit: " ); 
			 value = input.nextDouble(); 
			 
		  } // end while

		  // termination phase
		  // if user entered at least one amount...
		  if ( valueCounter != 0 ) 
		  {
			 // calculate commission of total amount
			 Commission = ((double) total /100)* 9; 
			 total = (double) total;
			 earnings = (double)Commission + 200;
			 				 
			 // display everything 
			 System.out.printf("Items Sold : " + valueCounter);
			 System.out.printf("\nTotal Amount: $%.2f\n", total);
			 System.out.printf("Commission: $%.2f\n", Commission);
			 System.out.printf("Earnings: $%.2f\n", earnings);
		  } // end if
		  else // no values were entered, so output appropriate message
			 System.out.println( "No values were entered" ); 
		   // end method 
	
	 // end class Sales

	}
}






I finished the first part but i don't know where and what to put for second part. I hope somebody can help, Thanks You. The output should look like this:

http://cypresscolleg...ssign4Extra.PNG

Is This A Good Question/Topic? 0
  • +

Replies To: Saleperson's Earnings

#2 javafreak  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 11
  • View blog
  • Posts: 97
  • Joined: 21-September 09

Re: Saleperson's Earnings

Posted 01 October 2009 - 09:44 PM

//Ravi Shah
//Assignment 4
//Sales.java
//10/01/09

import java.util.Scanner;// program uses class Scanner

public class Sales
{
public static void main(String[] args)
{
new Sales ();
Scanner input = new Scanner( System.in );

double total; // sum of values
double Commission=0; // Commission earned
double earnings=0;// number with decimal point for average

total = 0; // initialize total
int valueCounter = 0; // initialize loop counter

System.out.print( "Enter item Value, or -1 to quit: " );
double value = input.nextDouble();

// loop until sentinel value read from user
while ( value != -1 )
{
total = total + value; // add value to total
valueCounter = valueCounter + 1; // increment counter

// prompt for input and read next value from user
System.out.print( "Enter item Value, or -1 to quit: " );
value = input.nextDouble();


} // end while

// termination phase
// if user entered at least one amount...
if ( valueCounter != 0 )
{
if ( value>350.00 )
{
Commission = ((double) total /100)* 9+20;
total = (double) total;
earnings = (double)Commission + 200;

}
else if(value<350.00)
{
// calculate commission of total amount
Commission = ((double) total /100)* 9;
total = (double) total;
earnings = (double)Commission + 200;
}
else
{
System.out.println("enter the valid ones");
}
}
// display everything
System.out.printf("Items Sold : " + valueCounter);
System.out.printf("\nTotal Amount: $%.2f\n", total);
System.out.printf("Commission: $%.2f\n", Commission);
System.out.printf("Earnings: $%.2f\n", earnings);
// end if


// end class Sales

}
}
Was This Post Helpful? 1
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Saleperson's Earnings

Posted 02 October 2009 - 01:49 PM

View Postjavafreak, on 1 Oct, 2009 - 08:44 PM, said:

//Ravi Shah
//Assignment 4
//Sales.java
//10/01/09

import java.util.Scanner;// program uses class Scanner

public class Sales
{
public static void main(String[] args)
{
new Sales ();
Scanner input = new Scanner( System.in );

double total; // sum of values
double Commission=0; // Commission earned
double earnings=0;// number with decimal point for average

total = 0; // initialize total
int valueCounter = 0; // initialize loop counter

System.out.print( "Enter item Value, or -1 to quit: " );
double value = input.nextDouble();

// loop until sentinel value read from user
while ( value != -1 )
{
total = total + value; // add value to total
valueCounter = valueCounter + 1; // increment counter

// prompt for input and read next value from user
System.out.print( "Enter item Value, or -1 to quit: " );
value = input.nextDouble();


} // end while

// termination phase
// if user entered at least one amount...
if ( valueCounter != 0 )
{
if ( value>350.00 )
{
Commission = ((double) total /100)* 9+20;
total = (double) total;
earnings = (double)Commission + 200;

}
else if(value<350.00)
{
// calculate commission of total amount
Commission = ((double) total /100)* 9;
total = (double) total;
earnings = (double)Commission + 200;
}
else
{
System.out.println("enter the valid ones");
}
}
// display everything
System.out.printf("Items Sold : " + valueCounter);
System.out.printf("\nTotal Amount: $%.2f\n", total);
System.out.printf("Commission: $%.2f\n", Commission);
System.out.printf("Earnings: $%.2f\n", earnings);
// end if


// end class Sales

}
}


:code:

not only in your signature :)
Was This Post Helpful? 0
  • +
  • -

#4 Guest_InfiniteDED*


Reputation:

Re: Saleperson's Earnings

Posted 01 March 2010 - 03:53 PM

I am working code similar to this and pretty much for the same problem. I am trying to figure out how to count the high profitable items and add the bonus of 20.00 to the total earnings once an item over 350.00 is sold. Here is the problem.

Any items with value more than $350.00 are considered as high profitable. The company will pay $20 bonus for each high profitable item in addition to the sales commission. Modify your program to add bonus. For example, the same input values as listed in the book will yield the output:

My coding so far corrected to look like the ones above, I appreciate any help. Thank you

import java.util.Scanner;// program uses class Scanner

public class Assign4
{
	public static void main(String[] args)
	{
		new Sales ();
		Scanner input = new Scanner( System.in );

		double total; // sum of values
		double Commission=0; // Commission earned
		double earnings=0;// number with decimal point for average
		double bonus=0;// bonus amount for high value items

		total = 0; // initialize total
		int valueCounter = 0; // initialize loop counter

		bonus = 0; // initialize bonus
		int bonusCounter = 0; //initialize bonus counter

		System.out.print( "Enter item Value, or -1 to quit: " );
		double value = input.nextDouble();

		// loop until sentinel value read from user
		while ( value != -1 )
		{
			total = total + value; // add value to total
			valueCounter = valueCounter + 1; // increment counter

			// prompt for input and read next value from user
			System.out.print( "Enter item Value, or -1 to quit: " );
			value = input.nextDouble();


} // end while

// termination phase
// if user entered at least one amount...
if ( valueCounter != 0 )
{
	if ( value>=350.00 )
	{
		bonusCounter = bonusCounter + 1; // bonus counter
		// calculate commission with bonus earnings for high value item
		Commission = ((double) total /100)* 9+20;
		total = (double) total;
		earnings = (double)Commission + 200;
	}
	else if(value<350.00)
	{
		// calculate commission of total amount
		Commission = ((double) total /100)* 9;
		total = (double) total;
		earnings = (double)Commission + 200;
	}
}
// display everything
System.out.printf("Items Sold : " + valueCounter);
System.out.printf("\nTotal Amount: $%.2f\n", total);
System.out.printf("Commission: $%.2f\n", Commission);
System.out.printf("High profitable items: " +bonusCounter);
System.out.printf("\nBonus : $%.2f\n", bonus);
System.out.printf("Earnings: $%.2f\n", earnings);
// end if


// end class Assign4

}
}

Was This Post Helpful? 1

Page 1 of 1