The price p and the quantity x sold of a certain product obey the demand equation
x =- 8p + 80, 0 p l 10
(a) Express the revenue R as a function of x.
(b) What is the revenue if 24 units are sold?
(c) What quantity x maximizes revenue? What is the maximum revenue?
(d) What price should the company charge to maximize revenue?
Solution
A.
Revenue = Price*quantity
x = -8p + 80, and 0 <= P <= 10
8p = 80 - x
p = -x/8 + 10
R = p*x
R = x*(-x/8 + 10)
R = -x^2/8 + 10x
B.
x = 24
R = -x^2/8 + 10x
R = -24^2/8 + 10*24
R = 168
C.
In this parabolic equation
R = -x^2/8 + 10x
a = -1/8, b = 10
maximize x = -b/2a
x = -10/(2*(-1/8)) = 40
maximum revenue
R = -x^2/8 + 10x
R = -40^2/8 + 10*40 = 200
D.
p = -x/8 + 10
so for x = 40
p = -40/8 + 10 = 5
price = 5.
The Story of Village Palampur Class 9 Free Study Material PDF
this is java. problem.i already make employee class. but i can not.pdf
1. this is java. problem.
i already make employee class. but i can not make employeetester class. i want to know
Employeetester class.
EmployeeTester class:
Write a main method that produces a dialog like this:
-->Enter a name : dave
-->Enter hours worked (7 values separated by spaces): 5 2 1 0 0 3 3
Output: dave worked for 5 day(s) for a total of 14.0 hours.
-->Enter a day of the week (0-6): 2
Output: Hours worked on day 2 is 1.0
************and this is my employee class.**********************
public class Employee {
private double[] hours=new double[7];
private String name;
public Employee(String name){
this.name=name;
}
public double getHours(int day){
return hours[day];
}
public void setHours(int day,double hrs){
hours[day]=hrs;
}
public int numDaysWorked(){
int totalD=0;
for(int i=0;i<7;i++){
if(hours[i]==0.0){
}else{
totalD=totalD+1;
}
}
return totalD;
}
2. public double totalHours(){
double totalH=0;
for(int i=0;i<7;i++){
if(hours[i]==0.0){
}else{
totalH=totalH+hours[i];
}
}
return totalH;
}
public String toString(){
return name+" Worked " +numDaysWorked() + " day(s) for a total of "+totalHours() +
"hours .";
}
}
Solution
Note:
I have made some changes to the Employee class which have provided to meet the required
output.Thank You.
________________________
Employee.java
public class Employee {
//Creating an double type array of size 7
private double[] hours=new double[7];
//Declaring variable
private String name;
//Parameterized constructor
public Employee(double[] hours, String name) {
super();
this.hours = hours;
this.name = name;
}
3. //Setters and getters
public double[] getHours() {
return hours;
}
public void setHours(double[] hours) {
this.hours = hours;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
//This method will calculate the no of days worked by an employee
public int numDaysWorked(){
int totalD=0;
for(int i=0;i<7;i++){
if(hours[i]!=0.0){
totalD=totalD+1;
}
}
return totalD;
}
//This method will return the total no of hours worked by an employee
public double totalHours(){
double totalH=0;
for(int i=0;i<7;i++){
//Calculating the total hours worked
totalH=totalH+hours[i];
}
4. return totalH;
}
//this method will return the hours worked on particular day of an employee
public double hoursWorkedOnParticularday(int day)
{
return hours[day];
}
//this method will display the contents of an object inside it
public String toString(){
return name+" Worked " +numDaysWorked() + " day(s) for a total of "+totalHours() + "
hours .";
}
}
____________________
EmployeeTester.java
import java.util.Scanner;
public class EmployeeTester {
public static void main(String[] args) {
//Declaring variables
String name;
double tot_hours=0;
int no_of_days_worked=0;
int week_day=0;
//Scanner object is used to get the inputs entered by the user
Scanner sc=new Scanner(System.in);
//Creating an double type array of size 7
double hours[]=new double[7];
//getting the name of an employee entered by the user
System.out.print("Enter a name : ");
5. name=sc.next();
/* Getting the no of hours worked on each day by
* an employee and populating those values into an array
*/
System.out.print("Enter hours worked (7 values separated by spaces):");
for(int i=0;i<7;i++)
{
hours[i]=sc.nextDouble();
}
//creating an Employee class object by passing the inputs values as arguments
Employee emp=new Employee(hours, name);
//calling the methods on the Employee clas object
tot_hours=emp.totalHours();
no_of_days_worked=emp.numDaysWorked();
System.out.println(emp.toString());
//getting the day of the week value entered by the user
System.out.print("Enter a day of the week (0-6):");
week_day=sc.nextInt();
//Displaying the result
System.out.println("Hours worked on day "+week_day+" is
"+emp.hoursWorkedOnParticularday(week_day));
}
}
_____________________
output:
Enter a name : dave
Enter hours worked (7 values separated by spaces):5 2 1 0 0 3 3
dave Worked 5 day(s) for a total of 14.0 hours
.
Enter a day of the week (0-6):2