Java | JSP | JSF Answers

Questions answered by Experts: 3 611

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Provide a method calculatePrice() that calculates and returns the price of this sandwich according to the rates given in the above table. E.g. the price of a sandwich with 3 bread slices, 2 cheese slices, 2 tomato slices, 3 patties, mustard, no ketchup, no ice berg with grilling will be calculated as 3 * 20 + 2 * 30 + 2 * 5 + 3 * 70 + 5+ 0 + 0 + 10 . Provide a method applyDiscount(double disc) that calculates the price, applies the discount % given in the argument and returns the discounted price of the sandwich.E.g. if the method is called on a sandwich whose real price returned by the calculatePrice function is 550 and applyDiscount(10) is called, then a ten percent discount will be calculated as 550 * 10/100 = 55. Now this function will return the discounted price as 550 – 55 = 495. (Please note that this is just an example, do not hard code these values in your function).  


Provide a method calculatePrice() that calculates and returns the price of this sandwich according to the rates given in the above table. E.g. the price of a sandwich with 3 bread slices, 2 cheese slices, 2 tomato slices, 3 patties, mustard, no ketchup, no ice berg with grilling will be calculated as 3 * 20 + 2 * 30 + 2 * 5 + 3 * 70 + 5+ 0 + 0 + 10 7. Provide a method applyDiscount(double disc) that calculates the price, applies the discount % given in the argument and returns the discounted price of the sandwich.E.g. if the method is called on a sandwich whose real price returned by the calculatePrice function is 550 and applyDiscount(10) is called, then a ten percent discount will be calculated as 550 * 10/100 = 55. Now this function will return the discounted price as 550 – 55 = 495. (Please note that this is just an example, do not hard code these values in your function).  



Provide a method applyDiscount(double disc) that calculates the price, applies the discount % given in the argument and returns the discounted price of the sandwich.E.g. if the method is called on a sandwich whose real price returned by the calculatePrice function is 550 and applyDiscount(10) is called, then a ten percent discount will be calculated as 550 * 10/100 = 55. Now this function will return the discounted price as 550 – 55 = 495. (Please note that this is just an example, do not hard code these values in your function). 8. Provide the toString method that returns a well formatted string showing the detailed composition of the sandwich e.g. Bread Slices : 2 Cheese Slices : 2 Patties: 1 Tomato Slices: 0 Mustard: No (if not added) Ketchup: Yes Iceberg : Yes Grilled: No Price: Rs. 200 (dummy value given here but you will calculate programmatically and provide correct value here) 


Consider a class representing a ClubSandwich. A sandwich is made of some number of bread slices, cheese slices, meat patties and tomato slices. The club sandwich might also contain (or not) mustard, ketchup, iceburg. The sandwich may or may not be grilled. Different composition of the sandwich will cost different prices according to what it contains A sample of the class is given on moellim. You can use the same file and provide the missing things. You are required to provide the following 1. A parameterized constructor taking 4 arguments for bread slices, cheese slices, meat patty number and tomato slices. The values of the rest of the variables will be initialized by default to true 2. Another parameterized constructor that takes argument for each of these variables and initializes them accordingly 3. Another parameterized constructor that takes argument for each of these variables and initializes them accordingly 4. Provide setters for mustard, ketchup, iceberg and gilled


 Different methods named sum need to be created in one class, explain what mechanism should be used. Then Illustrate with examples the different ways to achieve that.


Q2/ Java Data Types Assignment?


Object [ ] = { “Java”, 1.23F, true, false, 23, ‘a’, ‘b’,


23.4F, 45.6F}; Write the Java Program to sum only the


float variables or any data type.

<modifier>* <type> <name> [= <initial_value>}, public class Foo ( 1 2 5) private int x; private float y 10000.0F; private String name "Bates Motel"; - Question2: According to Syntax in above, specify class attribute(s) and variables

You are required to create a class called BuyDiesel so that you can represent your purchase information related to Diesel.


The class should include five pieces of information in the form of instance variable


1. the station’s location (type String)

2. the type of Diesel (type String)

3. the quantity (type int) of the purchase in liters

4. the price per liter (double)

5. the percentage discount (double) which is in terms of how much percentage is off.


Your class should have a constructor that initializes the five instance variables. Provide a set and a get method for each instance variable.


In addition, provide a method named getPurchaseAmount that calculates the net purchase amount


(i.e., multiplies the quantity by the price per liter) minus the discount, then returns the net amount you had to pay as a double value.

Write an application class named Diesel that demonstrates the capabilities of class Diesel

Purchase.


Shortest Job First Algorithm: Step1:Get the number of process. Step2:Get the id and service time for each process. Step3:Initially the waiting time of first short process as 0 and total time of first short is process the service time of that process. Step4:Calculate the total time and waiting time of remaining process. Step5:Waiting time of one process is the total time of the previous process. Step6:Total time of process is calculated by adding the waiting time and service time of each process. Step7:Total waiting time calculated by adding the waiting time of each process. Step8:Total turn around time calculated by adding all total time of each process. Step9:calculate average waiting time by dividing the total waiting time by total number of process. Step10:Calculate average turn around time by dividing the total waiting time by total number of process. Step11:Display the result.


First Come First Serve Algorithm: Step1: Create the number of process. Step2: Get the ID and Service time for each process. Step3: Initially, Waiting time of first process is zero and Total time for the first process is the starting time of that process. Step4: Calculate the Total time and Processing time for the remaining processes. Step5: Waiting time of one process is the Total time of the previous process. Step6: Total time of process is calculated by adding Waiting time and Service time. Step7: Total waiting time is calculated by adding the waiting time for lack process. Step8: Total turn around time is calculated by adding all total time of each process. Step9: Calculate Average waiting time by dividing the total waiting time by total number of process. Step10: Calculate Average turn around time by dividing the total time by the number of process. Step11: Display the result


LATEST TUTORIALS
APPROVED BY CLIENTS