Monday, September 15, 2014

Alex's Second Simple JAVA Program





Song:  It Keeps You Runnin'

Group:  The Doobie Brothers








Alex is starting his second week of AP Computer Science.
He is learning very simple programming in JAVA right now.

Alex is enjoying this class.

Although it is very simple right now...
I am sure he will be learning more about the algorithms 
behind the encoding of information...
as his class progresses.


This is Alex's second simple JAVA program.

He had completed this assignment in about 30 minutes.



/**
 * The Measurement Converter program, which converts between miles/feet, miles/kilometers,
 * pounds/kilograms, and gallons/liters.
 *
 * @Alex
 * @September 15, 2014
 */
public class MeasurementConverterV1
{
    public static void main(String[ ] args)
    {  
        //local variable declarations - assign actual values below
        double miles;                    // distance in miles
        double feet;                    // distance in feet
        double kilometers;             // distance in kilometers
        double pounds;                // mass in pounds
        double kilograms;            // mass in kilograms
        double gallons;             // volume in gallons
        double liters;             // volume in liters
        double gunits;            // acceleration in g-units
        double centigals;         // acceleration in centigals
        //...finish declaring local variables here, including end of line
        //...comments doccumenting purpose of each variable
     
       
        //convert feet to miles
        feet = 6230;
        miles = feet / 5280;
        System.out.println(feet + " ft. = " + miles + " mi.");
       
       
        //convert miles to feet
        miles = 1.17992;
        feet = miles * 5280;
        System.out.println(miles + " mi. = " + feet + " ft.");
       
       
        //convert miles to kilometers
        miles = 1.17992;
        kilometers = miles * 1.60934;
        System.out.println(miles + " mi. = " + kilometers + " km.");
       
       
        //convert kilometers to miles
        kilometers = 1.8989;
        miles = kilometers / 1.60934;
        System.out.println(kilometers + " km. = " + miles + " mi.");
       
     
        //convert pounds to kilograms
        pounds = 25.2;
        kilograms = pounds / 2.2046;
        System.out.println(pounds + " lb. = " + kilograms + " kg.");
       
       
        //convert kilograms to pounds
        kilograms = 11.4305;
        pounds = kilograms * 2.2046;
        System.out.println(kilograms + " kg. = " + pounds + " lb.");
       
       
        //convert gallons to liters
        gallons = 6.5;
        liters = gallons * 3.7854;
        System.out.println(gallons + " gal. = " + liters + " L");
       
       
        //convert liters to gallons
        liters = 24.6052;
        gallons = liters / 3.7854;
        System.out.println(liters + " L = " + gallons + " gal.");
       
       
        //Custom conversion: convert g-units to centigals
        gunits = 2;
        centigals = gunits * 98066.5;
        System.out.println(gunits + " G = " + centigals + " cgal.");
       
       
        //Custom conversion: convert centigals to g-units
        centigals = 196133;
        gunits = centigals / 98066.5;
        System.out.println(centigals + " cgal. = " + gunits + " G");
    }//end of main method
}//end of class



                                                 --------------------------------------------



The Modifiable Calculative Result Of Alex's Conversion Table Program



6230.0 ft. = 1.1799242424242424 mi.

1.17992 mi. = 6229.9776 ft.

1.17992 mi. = 1.8988924528000002 km.

1.8989 km. = 1.179924689624318 mi.

25.2 lb. = 11.4306450149687 kg.

11.4305 kg. = 25.1996803 lb.

6.5 gal. = 24.6051 L

24.6052 L = 6.500026417287473 gal.

2.0 G = 196133.0 cgal.

196133.0 cgal. = 2.0 G





Alex is still getting used to his new schedule.

But, overall, he is adapting well.

His learning is coming at a more rapid pace than was possible before.

And it is this...
his new online high school...
which gives him the ability and greater freedom to 
schedule his classes around his studies at UNR...
which had really sold us on changing his schools.

So far...
it has been working out very well.






2 comments:

  1. Do you have a suggestion on an app or website that teaches programming to younger kids? You may have written about it before but I don't recall off hand. I tried to introduce my son to Scratch over the weekend - he was somewhat interested but became frustrated when he could not get the tool to do what he wanted right away. The tool may have been too limiting, but he also was not nearly patient enough to learn it, Not sure he would have the patience to learn Java yet... probably need something more fun for now.

    ReplyDelete
  2. Yes, but Scratch is one of them :(

    My wife gave me a link to more elementary school level programming sites. I will email it to you. Also...here it is: http://readwrite.com/2013/04/19/how-to-raise-the-next-zuck-6-coding-apps-for-kids

    ReplyDelete

Please feel free to comment on this article.

Related Posts Plugin for WordPress, Blogger...