Programming Assignment #35

Code

/// Name: Dylan Sleeper
/// Period: 6
/// Program Name: Else and If
/// File Name: Weekday.java
/// Date Finished: 10/22/2015

import java.util.Scanner;

public class SpaceWeight{

    public static void main(String[] args){
    
        Scanner keyboard = new Scanner(System.in);
    
        System.out.print("Please enter your current weight: ");
        int weight = keyboard.nextInt();
        
        System.out.println();
        System.out.println("I have information for the following planets: ");
        System.out.println("1. Venus   2. Mars   3.Jupiter");
        System.out.println("4. Saturn  5. Uranus 6. Neptune");
        System.out.println();
        System.out.print("Which planet are you visiting? ");
        int planet = keyboard.nextInt();
        
        double newWeight = (double)weight;
        
        if(planet == 1){
            newWeight = newWeight * .78;
        }
        else if(planet == 2){
            newWeight = newWeight * .39;
        }
        else if(planet == 3){
            newWeight = newWeight * 2.65;
        }
        else if(planet == 4){
            newWeight = newWeight * 1.17;
        }
        else if(planet == 5){
            newWeight = newWeight * 1.05;
        }
        else if(planet == 6){
            newWeight = newWeight * 1.23;
        }
        
        System.out.println();
        System.out.println("Your weight would be " + newWeight + " pounds on that planet.");
    }

}

  

Outputs

Assignment 15