TermCommentPost For If Else Statement

17 Comments

  • Write a program that displays a histogram that shows the occurrences of each letter in a text area. Assume that the letters are not case- sensitive.

  • can you please create a java that will accepts some amount of money from the user and will count how many bills are there like thousands, hundreds, tens, and ones….

  • [code]
    import java.util.Scanner;
    public class AnthonyWhiteProg4
    {
    public static void main(String[] args)
    {
    Scanner stdIn = new Scanner(System.in);
    double speed; // User entered value
    double distance; // user entered value
    double stoppingDistance = speed * (2.25 + speed/21); // number

    System.out.print(“Enter your speed (mph): “);
    speed.stdIn.nextDouble();
    System.out.print(“Enter your tailgate distance: “);
    stoppingDistance.stdIn.nextDouble();

    if(stoppingDistance==tailGatingDistance);
    {
    system.out.println(“Minor wreck”);
    }
    if(stoppingdistance > tailGatingDistance);
    {
    system.out.println(“No problem”);
    }
    else
    {
    system.out.println(“Major wreck”);
    }
    } // end main
    } // end class
    [/code]

  • import java.util.*;
    public class AnthonyWhiteProg4
    {
    public static void main(String[] args)
    {
    Scanner stdIn = new Scanner(System.in);
    double speed; // User entered value
    double tailGatingDistance; // user entered value
    double stoppingDistance;
    System.out.print(“Enter your speed (mph): “);
    speed = stdIn.nextDouble();
    System.out.print(“Enter your tailgate distance: “);
    tailGatingDistance = stdIn.nextDouble();
    stoppingDistance = speed * (2.25 + speed/21); // number

    if(stoppingDistance==tailGatingDistance)
    {
    System.out.println(“Minor wreck”);
    }
    else if(stoppingDistance < tailGatingDistance)
    {
    System.out.println(“No problem”);
    }
    else
    {
    System.out.println(“Major wreck”);
    }
    } // end main
    } // end class

    This was my end results after going through all the errors. I am new to programming so any criticism is welcomed, but please be gentle. 🙂

Sponsors

Facebook Fans