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
Using the above code add a method that takes in three arrays, one for student names, one for final test marks and a last one for assignment mark. The method should then calculate the students qualifying mark (a student needs 50 or more to qualify) using the following weights: 40% of the test and 60% of the assignment, finally print out whether the person qualified or not
### Functional Interfaces and Lambda Expressions
------------------------------------------------
1. In the class LambdaExercise, create following static variables
1. countries of type List<String>
2. countryCapitals of type Map<String, String>
In a static block, initialize countries and countryCapitals with soe values
Define following static methods and provide the implementation as given below
- sortCountriesBylength
- Sort the List using Comparator, in descending order of number of characters in the country name.
If the number of characters are same for a country, it should be sorted alphabetically
(Use Comparator's static/default methods)
- removeCountry(String name)
- remove the countries whose name is greater than 6 characters
Execute the methods and display the results in main method
Define a POJO class Country with countryId and CountryName as member variables
- Define a POJO class Player with playerName, matchesPlayed, runs, highestScore, Country as member variables
- Create a class StreamOperationsExercise as below
- Create a List of Players, as a static variable, with some player objects
Define following static methods and provide the implementation using Java 8 streams API as given below
- displayPlayersForCountry(String country)
Display the name of players whose highest score is more than 100 and belong to a particular country
- getPlayerNames
Return a LinkedList containing names of all Players, whose have scored more than 5000 runs, sorted in descending order of names
- getAverageRunsByCountry(String country)
Return the average runs scored by players from a particular Country
- getPlayerNamesSorted
Return a list with names of Players sorted as per country and then by matchesPlayed(descending)
Execute the above methods in the main method.