Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me with this using Basic Java 8 The program is to do the following:

ID: 3832661 • Letter: P

Question

Please help me with this using Basic Java 8

The program is to do the following:

We need to print out with a System.out.println() statement what the chances are for at least one spaceship making it safely through some asteroids.

Of course the more space ships you send through the asteroids, the better the chances are that at least one will survive, but the more asteroids you have the chances of survival decrease.

So given the number of ships and number of asteroids, your program should do the following:

If the number of ships is 1 and the number of asteroids is between 0 and 500, print out "odds are 50/50."

if the number of ships is 2 to 50 and the number of asteroids is between 0 and 500, print out "odds are good".

if the number of ships is 51 to 100 and the number of asteroids is between 0 and 500, print out "odds very good".

if the number of ships is 1 and the number of asteroids is 501 to 3000, print out "odds are 3720 to 1!!!".

if the number of ships is 2 to 50 and the number of asteroids is between 501 and 3000, print out "odds not so good."

if the number of ships is 51 to 100 and number of asteroids is between 501 and 3000, print out "Odds are OK."

if the number of ships is 1 and the number of asteroids is 3001 or higher print "Don't ask...".

if the number of ships is 2 to 50 and the number of asteroids is 3001 or higher, print "odds are bad."

if the number of ships is 51 to 100 and the number of asteroids is 3001 or higher, print "Odds not good."

if the number of ships are 101 or greater, print "you have a big fleet! your chances are good" no matter how many asteroids there are.

Explanation / Answer

import java.util.Scanner;

public class PrintProgram {

  

   public static void main(String[] args) {

      

       Scanner sc = new Scanner(System.in);

      

       int ship, asteroids;

      

       System.out.print("Enter number of ships: ");

       ship = sc.nextInt();

      

       System.out.print("Enter number of asteroids: ");

       asteroids = sc.nextInt();

      

       if(ship == 1){

          

           if(asteroids>=0 && asteroids<=500)

               System.out.println("odds are 50/50.");

           else if(asteroids>=501 && asteroids<=3000)

               System.out.println("odds are 3720 to 1!!!");

           else if(asteroids>=3001)

               System.out.println("Don't ask...");

       }else if(ship>=2 && ship<=50){

           if(asteroids>=0 && asteroids<=500)

               System.out.println("odds are good");

           else if(asteroids>=501 && asteroids<=3000)

               System.out.println("odds not so good.");

           else if(asteroids>=3001)

               System.out.println("odds are bad.");

       }else if(ship>=51 && ship<=100){

           if(asteroids>=0 && asteroids<=500)

               System.out.println("odds very good");

           else if(asteroids>=501 && asteroids<=3000)

               System.out.println("Odds are OK.");

           else if(asteroids>=3001)

               System.out.println("Odds not good.");

       }else{

           System.out.println("you have a big fleet! your chances are good");

       }

      

       sc.close();

   }

}

/*

Sample run:

Enter number of ships: 44

Enter number of asteroids: 543

odds not so good.

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote