Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need a pseudocode, flowchart and UML class Diagram for both programs. Program 1: import java.util.Scanner; public class WindChillTemperature { public static void main(String[] args)

I need a pseudocode, flowchart and UML class Diagram for both programs.

Program 1:

import java.util.Scanner;

public class WindChillTemperature {

public static void main(String[] args) {

//Declaring variable

double f;

double temperature,wind_Velocity;

/*

* Creating a Scanner class object which allows user's input

*/

Scanner sc = new Scanner(System.in);

while(true)

{

//User inputs temperature

System.out.print("Enter the temperature in fahrenheit between -58F and 41F: ");

temperature=sc.nextFloat();

if(temperature<-58 || temperature>41)

{

System.out.print("Must be between -58F and 41F ");

continue;

}

else

break;

}

while(true)

{

//User input wind velocity

System.out.print("Enter the wind speed( >=2 ) in miles per hour : ");

wind_Velocity=sc.nextInt();

if(wind_Velocity<2)

{

System.out.println("Must be greater than or equal to 2");

continue;

}

else

break;

}

//Calling the method by passing the temperature and wind velocity as parameters.

f=windchill(temperature,wind_Velocity);

//Displays the Wind chill

System.out.printf("The Wind Chill index is %.4f",f);

}

//Method Implementation which calculates wind chill

public static double windchill(double temp,double windV)

{

//Calculates the wind chill

double windchill=35.74+(0.6125*temp)-(35.75*Math.pow(windV,0.16))+(0.4275*temp*Math.pow(windV,0.16));

return windchill;

}

}

Program 2:

import java.util.Scanner;

public class CostOfDriving {

public static void main(String[] args) {

//Declaring variables

double distanceToDrive,milesPerGallon,pricePerGallon,costOfDriving;

/*

* Creating a Scanner class object which allows user's input

*/

Scanner sc = new Scanner(System.in);

//Getting the input entered by the user

System.out.print("Enter the driving distance: ");

distanceToDrive=sc.nextDouble();

System.out.print("Enter miles per gallon: ");

milesPerGallon=sc.nextDouble();

System.out.print("Enter price per gallon: ");

pricePerGallon=sc.nextDouble();

//calculates the cost of Driving

costOfDriving=(distanceToDrive/milesPerGallon)*pricePerGallon;

//Displays the output

System.out.printf("The cost of driving is $: %.2f",costOfDriving);

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases 28th British National Conference On Databases Bncod 28 Manchester Uk July 2011 Revised Selected Papers Lncs 7051

Authors: Alvaro A.A. Fernandes ,Alasdair J.G. Gray ,Khalid Belhajjame

2011th Edition

3642245765, 978-3642245763

More Books

Students also viewed these Databases questions

Question

Evaluate the following limits using Taylor series. lim x1 In x

Answered: 1 week ago