Question: This is my code and please modify this to work. import java.util.Scanner; public class Project4 { public static void main(String[] args) { // TODO Auto-generated

This is my code and please modify this to work.
import java.util.Scanner;
public class Project4 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner hi = new Scanner(System.in); //I just use scanner with name of "Daeyoo".
while(kim.hasNextLine())
{
String str = hi.nextLine();
double a = hi.nextDouble();
double b = hi.nextDouble();
double sum = a+b;
double power = Math.pow(a,b);
double average = sum/2;
if(str.equals("+"))
{
System.out.printf("+ %.2e + %.2e = %.2e ",a,b,sum);
}
else if(str.equals("power"))
{
System.out.printf("%.2e power %.2e = %.2e ", a,b,power);
}
else if(str.equals("average"))
{
System.out.printf("%.2e average %.2e = %.2e ",a,b,average);
}
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
