· A client (a person who wants a program developed) who owns a car rental company wants a program developed that will estimate the litres of gas needed to drive a car a given distance in kilometers on a highway for a road-trip. Currently staff at the rental desk need to ask the customer the estimated mileage the car will be driven on the highway, they then need to look up the fuel efficiency of the car to be rented and use that within the math needed to determine the amount of gasoline in litres the customer will need for their road-trip. A typical fuel economy for the rental company's cars is 6.8L/100Km, most customers have round trips of 900Km on the highway, for example from Ottawa to Toronto. The program should allow the entry of the distance to drive, the litres per 100Km for efficiency, and output the Litres of gasoline needed, rounded up to a whole number when producing the result.
· You would only need to input 6.8 for the efficiency, work with 100Km internally in the program as part of your math.
· Write out briefly how you would do each step, as if you were the staff member. Including examples of math calculations you would perform either by hand, or with the assistance of a calculator.
· Type this into your MS Word document as part of your submission.
· Determine what objects, the properties of the objects, and behaviors would be required for an object oriented program, start with simple UML class diagrams and as you work out more details document the design with a detailed UML class diagram.
· Write pseudo-code as the basis of your algorithm, as well as create a flowchart. You should reference the lecture notes, as well as your textbook by Joyce Farrell [2] as learning resources for this part of the assignment.
· You should show object instantiation in the flowchart as variable declarations, then use method calls to methods. Note, you are not required to document get/set accessor, mutator methods in your algorithm or flowchart in detailed step-by-step, only method main and any method(s) that perform math calculations.
· You may hand-draw the flowchart and UML class diagram for this assignment instead of using software, just use a ruler and print legibly.
· Alternatively a software program like Diagrams.net can be used for flowchart while a software program like UMLet can be used to create the UML class diagrams. Other programs like MS Visio, or even MS Word can be used instead.
· Your name as author must appear within any diagrams you create.
· If working on paper either scan the diagram into your computer, or use a cell phone to take a picture and email it to yourself. Both your pseudocode and flowchart should be placed into your MS Word document, the pseudocode as text while the flowchart should be an image. Note: The pseudocode and flowchart should document the exact same algorithm.
· Your UML diagram provides a high-level view of the Structure of the objects, while the pseudocode and flowcharts provide the basis for the sequential logic within method main.
· As per the lecture notes, use a table within your MS Word document to test the algorithm. Consider picking numbers that might be expected as input and work through the algorithm documenting expected outputs, you may use a calculator.
· If there is a problem with the algorithm based on this desk-check correct the pseudocode and flowchart, UML class diagram(s) and repeat this step again.
· You are to use the Eclipse IDE to create your Java program, use a project name like Assignment 02.
· Don’t forget to comment your code files, with the expected code header.
· You are not required to copy and paste code into the MS Word document, however your .java file(s) must be submitted.
· Compile and run your program, using your documented test values.
· Take a screen shot of Command prompt window, or a rectangular selection of the Eclipse Console View depending on your development environment, ensure your name as output by the program is captured in the image.
· Re-create your testing table from step 3 in this section, but document what the program outputs are, do they match expectations?
· Test with some invalid inputs, and document what happens. Note that some input will crash your program, this is okay as you may not know how to fix this at this point in the course. Document what the error messages are in your test plan. Suggested invalid tests: enter a String instead of a number.
2. Create another class Report holding a main function. This class will ask the user for type of data to be displayed like 1. Medical report 2. Grocery purchase bill 3. Electricity bill 4. Exit Once the choice is selected, write the code for invoking appropriate methods of the respective class for reading the details of three household and display the information.
1. Implement the following using java:
Consider three classes named Diagnosis, Grocery and Electricity containing variables for medical report of the patient, grocery bill, electricity and methods for getting and displaying the details from the user.
a. Diagnosis class can have instance variables for patient id, name, symptoms, COVID_Status and functions for reading these values from the user and displaying it.
b. Grocery class can have instance variables required for computing a monthly expense on grocery such as Monthly_budget, No_of_times_grocery_purchased, Average_ expense_on_each_purchase, and functions for reading these values and computing the Amount_spent_on_grocery and percentage_of_budget_alloted.
c. Electricity class can contain the instance variables such as amount of units consumed every month and electricity bill for every month and average electricity consumption for every day. It can have functions for reading the values from the user and computing the electricity bill and consumption/month.
Create another class Report holding a main function. This class will ask the user for type of data to be displayed like 1. Medical report 2. Grocery purchase bill 3. Electricity bill 4. Exit Once the choice is selected, write the code for invoking appropriate methods of the respective class for reading the details of three household and display the information in java program
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString.trim().split("\n").map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
/* Please do not modify anything above this line */
class Mobile {
constructor(brand, ram, battery, isOnCall, song) {
this.brand = brand;
this.ram = ram;
this.battery = battery;
this.isOnCall = isOnCall;
this.song = song;
this.isOnCall = false;
}
onCall() {
this.isOnCall = true;
}
onCall() {
this.isOnCall = false;
}
removeCharging() {
console.log("Please remove charger");
}
charging() {
if (this.battery < 100) {
this.battery = 100;
console.log(`Mobile Charged ${this.battery}%`);
} else {
console.log(`Mobile is fully charged`);
this.removeCharging();
}
}
playMusic() {
this.song = this.song;
console.log(`Playing ${this.song} song`);
}
stopMusic() {
this.song = this.song;
console.log('Music stopped');
}
makeCall() {
console.log("Calling...");
}
endCall() {
if (this.isOnCall === false) {
this.isOnCall = true;
console.log('No ongoing call to end');
} else {
console.log('Call Ended');
}
}
}
/* Please do not modify anything below this line */
function main() {
const brand = readLine();
const ram = readLine();
const battery = parseInt(readLine());
const song = readLine();
const isOnCall = JSON.parse(readLine());
const myMobile = new Mobile(brand, ram, battery, isOnCall, song);
console.log(`Mobile charged ${myMobile.battery}%`); // The Mobile battery charged percentage
myMobile.charging(); // The Mobile charging
myMobile.playMusic(); // The Mobile will start playing a song
myMobile.stopMusic(); // The Mobile will stop playing a song
myMobile.endCall(); // The Mobile will end a call.
myMobile.makeCall(); // The Mobile will make a call.
myMobile.endCall(); // The Mobile will end a call.
}
Sample Input 1
Apple
2 GB
90
Waka Waka
false
Sample Output 1
Mobile charged 90%
Mobile charged 100%
Playing Waka Waka song
Music stopped
No ongoing call to end
Calling...
Call Ended
Sample Input 2
Samsung
8 GB
100
Gangnam Style
true
Sample Output 2
Mobile charged 100%
Mobile is fully charged
Please remove charging
Playing Gangnam Style song
Music stopped
Call Ended
Calling...
Call Ended
there is some error in the testcases, help me for getting this out.
Why Is Method main Declared static?
When writing a data structure, what should be our guidelines for choosing the right Java Collection?
Split and Replace
Given three strings
inputString, separator and replaceString as inputs. Write a JS program to split the
inputString with the given separator and replace strings in the resultant array with the replaceString whose length is greater than 7.
Quick Tip
finding weather all the given input array elements are strings
Check values in the Array is a String
Given an array
Sample Input 1
[ 'frozen', 'rock', 'stained', 'basket' ]
Sample Output 1
true
Sample Input 2
[ 'recycling', 70, 'pastime', 'animal' ]
Sample Output 2
false