Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started