Write Java Program Convert Power Kilowatts Kw Electric Car Motor Horsepower Hp Follows Pro Q43780834

Write a Java program to convert power in kilowatts (kW) of anelectric car motor to horsepower (hp) as follows:

Prompt the user to enter the power in kilowatts (kW) of theelectric car motor.

Convert the power to horsepower. In a comment, reference yoursource for the conversion factor (non-wiki source). (As a roughestimate, 1 hp equals ~0.75 kW.)

Output the power in horsepower (hp). Print the result with 2decimal places.

Once this is working, add a do-while loop such that, after thepower is displayed, the user sees:

“Repeat the calculation (Y/N)?: ”

If the user enters the character ‘Y’ or ‘y’, then repeat theprocess of requesting new user input, calculating and displayingthe converted power. If the user enters any other character, thenquit.

Expert Answer


Answer to Write a Java program to convert power in kilowatts (kW) of an electric car motor to horsepower (hp) as follows: Prompt t…

Write Java Program Convert Power Kilowatts Kw Electric Car Motor Horsepower Hp Follows Pro Q43786926

Write a Java program to convert power in kilowatts (kW) of anelectric car motor to horsepower (hp) as follows:

Prompt the user to enter the power in kilowatts (kW) of theelectric car motor.

Convert the power to horsepower. In a comment, reference yoursource for the conversion factor (non-wiki source). (As a roughestimate, 1 hp equals ~0.75 kW.)

Output the power in horsepower (hp). Print the result with 2decimal places.

Once this is working, add a do-while loop such that, after thepower is displayed, the user sees:

“Repeat the calculation (Y/N)?: ”

If the user enters the character ‘Y’ or ‘y’, then repeat theprocess of requesting new user input, calculating and displayingthe converted power. If the user enters any other character, thenquit.

Expert Answer


Answer to Write a Java program to convert power in kilowatts (kW) of an electric car motor to horsepower (hp) as follows: Prompt t…

Write Java Program Design Class Mentioned Picture Please Describe Codes Correct Solutions Q43838692

Given an array of windows in the plane, we want to count how many overlapping and how many enclosing pairs of windows there aWrite a JAVA program to designthe class mentioned in the picture. Please describe your codes.Correct solutions only please.

Given an array of windows in the plane, we want to count how many overlapping and how many enclosing pairs of windows there are (without double counting). A window is the region of the plane enclosed by a rectangle with sides parallel to the x and y axes. A window can be abstracted as an object with the 4 fields of doubles: (left, right, bottom, top). These fields should satisfy the invariant: left < right and bottom < top. The window is the Cartesian product of the x-interval (left, right) and the y-interval [bottom, top), i.e., the set of points (x,y) in the plane such that left <x<right and bottom <y<top. Consider a pair of windows w, and w,. We say these two windows overlap if they have a common interior point (just touching boundaries is not enough). We say w, encloses w, if no part of w, is outside wo. (Note that the first relationship is symmetric but the second is anti-symmetric.) Design a class called Window with the following fields and methods: (Note: you should not confuse this with the Java API class java.awt.Window.) • Protected fields left, right, bottom, top. • A constructor that throws an exception named InvalidWindowException if the given 4 fields do not satisfy the above invariant. Public getters and setters for these fields. The setters also throw Invalid WindowException if invalid field value is attempted to be set. • Boolean instance method encloses(Window w) returns true if and only if the instance window encloses the argument window w. • Boolean instance method overlaps(Window w) returns true if and only if the instance window overlaps the argument window w. • Static method overlapCount(Window[] windows) returns the number of (unordered) overlapping pairs of windows in the input array windows. Static method enclosureCount(Window[] windows) returns the number of (ordered) enclosing pairs of windows in the input array windows. main() method runs some interesting test cases of the above methods. Show transcribed image text Given an array of windows in the plane, we want to count how many overlapping and how many enclosing pairs of windows there are (without double counting). A window is the region of the plane enclosed by a rectangle with sides parallel to the x and y axes. A window can be abstracted as an object with the 4 fields of doubles: (left, right, bottom, top). These fields should satisfy the invariant: left

Expert Answer


Answer to Write a JAVA program to design the class mentioned in the picture. Please describe your codes. Correct solutions only pl…

Write Java Program Following Tasks Use Java Api Documentation Find Suitable String Methods Q43905345

Write a Java program to the following tasks. Use Java API Documentation to find suitable String methods to complete the tasks

Write a Java program to the following tasks. Use Java API Documentation to find suitable String methods to complete the tasks when needed. • Declare a String variable str. • Set the value of str to your complete name, one word for your first name (without space) and one word for your last name (without space), having one space between them, and all in lowercase. (Therefore, the format of the String str is something like “xxxxXX XXXXXXxxxx”.) Display the value of str. Display the length of str. • Extract your first name from str and put it into another String variable, called firstName. Do the same for your last name and put it into a String variable, called lastName. • Declare another String variable, str2, and initialize it with lastName, a comma, a space and then firstName. • Display str2. • Display the position (index) of the first occurrence of the last character of your lastname in your firstname. • Display the position (index) of the last occurrence of the first character of your lastname in your firstname. • Replace the first character of the firstName variable with its uppercase and put it back into firstName variable. • Do the same for lastName. • Display firstName and lastName. *Note that you are not allowed to use fixed numbers to apply the requested tasks. This means that when you do the tasks, assume that you don’t exactly know the exact contents of the variables. Activity 2. Follow the steps to implement a class for the following requirements’ specification: Alice wants to store the information of all her books. She would like to be able to create new book by giving its name as the mandatory value. Sometimes she creates new book by indicating name and author. Except name and author, any book can have year of publication and number of pages. Alice wants to have the following functionalities as well: 1- Get the name of a book 2- Get the author of a book 3- Get the year of publication of a book 4- Get the number of pages of a book 5- Set/change each of the information of a book Having the above requirements, provide a Java class for Alice, named Book, by using all the steps we learned in order Show transcribed image text Write a Java program to the following tasks. Use Java API Documentation to find suitable String methods to complete the tasks when needed. • Declare a String variable str. • Set the value of str to your complete name, one word for your first name (without space) and one word for your last name (without space), having one space between them, and all in lowercase. (Therefore, the format of the String str is something like “xxxxXX XXXXXXxxxx”.) Display the value of str. Display the length of str. • Extract your first name from str and put it into another String variable, called firstName. Do the same for your last name and put it into a String variable, called lastName. • Declare another String variable, str2, and initialize it with lastName, a comma, a space and then firstName. • Display str2. • Display the position (index) of the first occurrence of the last character of your lastname in your firstname. • Display the position (index) of the last occurrence of the first character of your lastname in your firstname. • Replace the first character of the firstName variable with its uppercase and put it back into firstName variable. • Do the same for lastName. • Display firstName and lastName. *Note that you are not allowed to use fixed numbers to apply the requested tasks. This means that when you do the tasks, assume that you don’t exactly know the exact contents of the variables. Activity 2. Follow the steps to implement a class for the following requirements’ specification: Alice wants to store the information of all her books. She would like to be able to create new book by giving its name as the mandatory value. Sometimes she creates new book by indicating name and author. Except name and author, any book can have year of publication and number of pages. Alice wants to have the following functionalities as well: 1- Get the name of a book 2- Get the author of a book 3- Get the year of publication of a book 4- Get the number of pages of a book 5- Set/change each of the information of a book Having the above requirements, provide a Java class for Alice, named Book, by using all the steps we learned in order

Expert Answer


Answer to Write a Java program to the following tasks. Use Java API Documentation to find suitable String methods to complete the …

Write Java Program Print Following Pattern Squared Use Nested Loop 5 45 345 2345 12345 Get Q43868232

write a java program that will print out the following patternbut squared. Use nested for loop

5

45

345

2345

12345

to get

25

16 25

9 16 25

4 9 16 25

1 4 9 16 25

Expert Answer


Answer to write a java program that will print out the following pattern but squared. Use nested for loop 5 45 345 2345 12345 to g…

Write Java Program Print Following Pattern Use Nested Loop 5 45 345 2345 12345 Q43868194

write a java program that will print out the following pattern.Use nested for loop

5

45

345

2345

12345

Expert Answer


Answer to write a java program that will print out the following pattern. Use nested for loop 5 45 345 2345 12345…

Write Java Program Read Add Two Numbers Type Integer Display Result Q43789305

Write a JAVA program to read and then add two numbers typeinteger and display the result.

Expert Answer


Answer to Write a JAVA program to read and then add two numbers type integer and display the result. …

Write Java Program User Input Must Output User Typed B Test Input C D E Output 6e D C Test Q43889112

Write a java program, when user input  foo bar,

it must output It must output exactly: 2 bar foo

When user typed

a b “test input” c d e

output is:

6e d c test input b a

(no quote marks and total 6, not 7)

foo bar It must output exactly: 2 bar foo Show transcribed image text foo bar
It must output exactly: 2 bar foo

Expert Answer


Answer to Write a java program, when user input , it must output When user typed a b “test input” c d e output is: 6 e d c test in…

Write Java Program Write Java Application Reads Three Integers User Displays Sum Product A Q43862298

Write a Java program:

Write a Java application that reads three integers from the userand displays the sum, product, average, smallest, largest, andmedian of the numbers. Use the following sample code as aguide.

import java.util.Scanner;

public class IntegerOps {

public staticvoid main(String[] args)

{

int num1, num2, num3;

int sum,;

// Use Scanner class to read the three integer

sum = sum(num1, num2, num3); //The sum methodcalculates the sum

//Call product method to calculate the product

//Call product method to calculate the average (real number)

//Call product method to calculate the smallest number

//Call product method to calculate the largest number

//Call product method to calculate the median of the 3numbers

System.out.println(“Sum = ” +sum);

// Print the product, average, smallest, largest, and median inseparate lines

}

/**

* This method calculates the sum of 3 integers

* @param x the first integer

* @param y the second integer

* @param z the third integer

* @return the sum of the 3 integers

*/

public staticint sum(int x,int y, int z)

{

return x + y + z;

}

}

Below is an example of how to calculate the median of 3integers.

public class Test {

public staticvoid main(String[] args) {

int x= 6;

int y = 4;

int z = 8;

int larger1, smaller1, larger2, smaller2,median;

smaller1 = x; //assuming the smaller of x & y is x

larger1 = y; //assuming the larger of x & y is y

smaller2 = x; //assuming the smaller of x & z is x

larger2 = z; //assuming the larger of x and z is z

if(y < x) //fix the above assumptions of thex & y if needed

{

smaller1 = y;

larger1 = x;

}

if(z < x) //fix the above assumptions of thex & z if needed

{

smaller2 = z;

larger2 = x;

}

median = smaller2; //assume the median is smaller2. We will fixit later if needed

if (smaller1 == smaller2) //if the smaller ofthe two pairs is the same, then the median is one of thefollowing

{

if(larger1 < larger2) //the median cannot bethe largest number, so it is the smaller of the two largest

median = larger1;

else

median = larger2;

}

else if (smaller1 >smaller2) //if the smaller of the two pairs are not equal, then thelarger of the two is the median

median = smaller1;

//could have added an else here, but is really the aboveassumption of median=smaller2 so it is omitted.

System.out.printf(“median=%d”,median);

}

}

Expert Answer


Answer to Write a Java program: Write a Java application that reads three integers from the user and displays the sum, product, av…

Write Java Program Write Java Application Reads Three Integers User Displays Sum Product A Q43866085

Write a Java program:

Write a Java application that reads three integers from the userand displays the sum, product, average, smallest, largest, andmedian of the numbers. Use the following sample code as aguide.

import java.util.Scanner;

public class IntegerOps {

public staticvoid main(String[] args)

{

int num1, num2, num3;

int sum,;

// Use Scanner class to read the three integer

sum = sum(num1, num2, num3); //The sum methodcalculates the sum

//Call product method to calculate the product

//Call product method to calculate the average (real number)

//Call product method to calculate the smallest number

//Call product method to calculate the largest number

//Call product method to calculate the median of the 3numbers

System.out.println(“Sum = ” +sum);

// Print the product, average, smallest, largest, and median inseparate lines

}

/**

* This method calculates the sum of 3 integers

* @param x the first integer

* @param y the second integer

* @param z the third integer

* @return the sum of the 3 integers

*/

public staticint sum(int x,int y, int z)

{

return x + y + z;

}

}

Below is an example of how to calculate the median of 3integers.

public class Test {

public staticvoid main(String[] args) {

int x= 6;

int y = 4;

int z = 8;

int larger1, smaller1, larger2, smaller2,median;

smaller1 = x; //assuming the smaller of x & y is x

larger1 = y; //assuming the larger of x & y is y

smaller2 = x; //assuming the smaller of x & z is x

larger2 = z; //assuming the larger of x and z is z

if(y < x) //fix the above assumptions of thex & y if needed

{

smaller1 = y;

larger1 = x;

}

if(z < x) //fix the above assumptions of thex & z if needed

{

smaller2 = z;

larger2 = x;

}

median = smaller2; //assume the median is smaller2. We will fixit later if needed

if (smaller1 == smaller2) //if the smaller ofthe two pairs is the same, then the median is one of thefollowing

{

if(larger1 < larger2) //the median cannot bethe largest number, so it is the smaller of the two largest

median = larger1;

else

median = larger2;

}

else if (smaller1 >smaller2) //if the smaller of the two pairs are not equal, then thelarger of the two is the median

median = smaller1;

//could have added an else here, but is really the aboveassumption of median=smaller2 so it is omitted.

System.out.printf(“median=%d”,median);

}

}

Expert Answer


Answer to Write a Java program: Write a Java application that reads three integers from the user and displays the sum, product, av…