I cannot run the example 3 , when i run it , it always show the result of computer science. can anyone help me ?
Write a program to plan your future, using the following data. The correct solution will have the results shown higher toward the top. Only one result per run! See the examples run below. MAJOR RESULT GPA computer science Greater than or I think you go to grad school to equal to 3.5 get a PhD in CS computer science Greater than or I think you should get an MS in equal to 3.0 but. CS while working in the field less than 3.5 Less than 3.0 There are lots of amazing jobs in computer science CS business Greater than 3.3 I think an MBA is in your future! premed Greater than 3.7 Med school, here you come Greater than or Having a college degree is a real equal to 2.0 benefit to your marketability Less than 2.0 You really need to work on your grades Example run 1 Enter your major computer science Enter your gpa 2 There are lots of amazing jobs in CS Example run 2: Enter your major: anthropology Enter your gpa: 2 Having a college degree is a real benefit to your marketability Example run 3 Enter your major premed Enter your gpa: 3.5 Having a college degree is a real benefit to your marketability
Expert Answer
Here i wrote the code in java programming language. I got the correct result that has been provided in question. I am sending snap of the result after running the code. |
I have provided the java code below. Thank you. |
import java.util.*;
class FuturePlan
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.print(“Enter your major: “);
String major=sc.nextLine();
System.out.print(“Enter your gpa: “);
double gpa=sc.nextDouble();
if(major.equals(“computer science”))
{
if(gpa>=3.5)
System.out.println(“I think you go to grad school to get a PhD in CS.”);
else if(gpa>=3.0 && gpa<3.5)
System.out.println(“I think you should get an MS in CS while working in the field.”);
else
System.out.println(“There are lots of amazing jobs in CS.”);
}
else if(major.equals(“business”) && gpa>3.3)
System.out.println(“I think in MBA is in your future!”);
else if(major.equals(“premed”) && gpa>3.7)
System.out.println(“Med school, here you come!”);
else if(gpa>=2.0)
System.out.println(“Having a college degree is a real benefit to your marketability.”);
else if(gpa<2.0)
System.out.println(“You really need to work on your grades!”);
}
}