CSC203 Week 1 Data Types Assignment

 

“Complete Exercise 2.24 from the text. Provide your source code here in the body of the post with a screen shot” of everything.

Quoting Professor Brooke-Fishinghawk

 Date Posted: 12 Mar 2009 @ 08 40 PM
Last Modified: 05 Apr 2009 @ 05 42 PM
Posted By: Ryan Bridglal
E-mail | Permalink
 

Responses to this post » (2 Total)

 
  1. Ryan Bridglal said...
    5:42 pm - April 5th, 2009

    originally posted: 1 Mar 09 2:16 AM MST

    Hello, surprisingly, the exercise was a small challenge; because the rules were to ONLY use the programming skills I learned within chapter 2! I found myself using more advanced methods. I flipped through that entire chapter about 10 times; just to make sure I could use a certain command! LOL… So solving the problem was not a challenge. But creating the program using only what we have learned from chapter 2 was a slight challenge. It’s easy to get carried away.

    Here’s my source code:

    /**
    * @author RyanJB, Ryan Bridglal,
    *
    *University of Advancing Technology
    *CSC203-D09FEB05
    *Professor Estabrook-Fishinghawk
    *02-28-09
    *
    *
    * Instructions: Write an application that reads five integers,
    * determines and prints the largest and smallest integers in
    * the group. Use only the programming techniques learned within
    * the chapter.
    */

    import java.util.Scanner;

    public class HighLowInteger {

    public static void main(String[] args) {

    //this allows the console to receive input
    Scanner input = new Scanner(System.in);

    //this identifies the variables
    int Number1;
    int Number2;
    int Number3;
    int Number4;
    int Number5;
    int LargeNumber;
    int SmallNumber;

    //introduction and begin program
    System.out.print(”Welcome to the High-Low # program!\nEnter 5 numbers of your choice,\nand I will tell you what the highest\nand lowest numbers were.\n\nPlease enter your first number:”);
    Number1 = input.nextInt();

    System.out.print(”Enter your second number:”);
    Number2 = input.nextInt();

    System.out.print(”Enter your third number:”);
    Number3 = input.nextInt();

    System.out.print(”Enter your fourth number:”);
    Number4 = input.nextInt();

    System.out.print(”Enter your fifth number:”);
    Number5 = input.nextInt();

    //this calculates the largest number
    LargeNumber = Number1;

    if (Number1 > LargeNumber)
    LargeNumber = Number1;

    if (Number2 > LargeNumber)
    LargeNumber = Number2;

    if (Number3 > LargeNumber)
    LargeNumber = Number3;

    if (Number4 > LargeNumber)
    LargeNumber = Number4;

    if (Number5 > LargeNumber)
    LargeNumber = Number5;

    //this calculates the smallest number
    SmallNumber = Number1;

    if (Number2 < SmallNumber)
    SmallNumber = Number2;

    if (Number3 < SmallNumber)
    SmallNumber = Number3;

    if (Number4 < SmallNumber)
    SmallNumber = Number4;

    if (Number5 < SmallNumber)
    SmallNumber = Number5;

    //displays the numbers and goodbye!
    System.out.println(”\nI’ve got your numbers and sorted\nthem based on the highest and lowest;\nhere’s the result:”);
    System.out.printf(”\n The Highest number is:%d”, LargeNumber);
    System.out.printf(”\n The Smallest number is:%d”, SmallNumber);
    System.out.println(”\n\nGoodBye!”);

    }

    }

    and here’s my screen shot:

  2. Ryan Bridglal said...
    5:45 pm - April 5th, 2009

 

Leave A Comment ...

 


You must be logged in to post a comment.


 XHTML:
You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
\/ More Options ...
Change Theme...
  • Role »
  • Posts »
  • Comments »
Change Theme...
  • VoidVoid (Default)
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LiteLightweight
  • No Child Pages...
  • No Child Pages...
  • No Child Pages...
  • No Child Pages...
  • No Child Pages...
  • No Child Pages...
  • No Child Pages...
  • No Child Pages...