Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * ---------------------------------------------------------------------------
- * File name: Project1.java
- * Project name: Project1
- * ---------------------------------------------------------------------------
- * Author’s name and email: Parker Reed parker.l.reed@gmail.com
- * Course-Section: 002
- * Creation Date: 9/25/2012
- * Last modified: (Parker, 9/25/2012, parker.l.reed@gmail.com)
- * ---------------------------------------------------------------------------
- */
- import java.util.Scanner; //import to get input from the keyboard
- /**
- * Class Name: Project1 <br>
- * Class Purpose: Project1 <br>
- *
- * <hr>
- * Date created: 9/25/2012
- * Last modified: Parker Reed, parker.l.reed@gmail.com, 9/25/2012
- * @author Parker Reed
- */
- public class Project1
- {
- /**
- * Method Name: main <br>
- * Method Purpose: To develop a simple program in Java that will interact with the
- * user through some dialog. It will ask the user for their name and the
- * and the number of hours of TV they watch per day. The program will then
- * display the total hours, days, years in 10 years they will have watched.
- *
- * <hr>
- * Date created: 9/25/2012 <br>
- * Last modified: 9/25/2012 <br>
- *
- * <hr>
- * Notes on specifications, special algorithms, and assumptions:
- * There are 24 hours in a day, 365 days in a year. Does not account for leap years.
- *
- * <hr>
- * @param String[] args - Command Line Arguments
- */
- public static void main(String[] args)
- {
- //***************************VARIABLE DECLARATIONS*****************************
- Scanner kb = new Scanner(System.in); //to get input from keyboard
- double hoursTV, //initializing the variables
- hoursTotal,
- daysTotal,
- yearsTotal;
- double years = 10; //allowing for the number of years to be changed
- String name; //creating the variable for the user's name
- //-----------------------------------------------------------------------------
- // introduce myself and prompt for the user's name
- //-----------------------------------------------------------------------------
- System.out.println("\n\n********************************************************\n");
- System.out.print("Hello, my name is Parker! What is your name? "); //prompt the user for their name
- name = kb.nextLine(); //store their name to the variable name
- //-----------------------------------------------------------------------------
- // ask the user for the number of hours they watch TV and store it to hoursTV
- //-----------------------------------------------------------------------------
- System.out.print("\nHello, " + name + "! How many hours of TV do you watch per day (on avg)? "); //prompt for number of hours
- hoursTV = kb.nextInt(); //store the number of hours to hoursTV
- System.out.println("\n\n********************************************************");
- System.out.print("\n");
- //-----------------------------------------------------------------------------
- // calculate and tell the user the number of hours, days, and years they will
- // watch TV in the next 10 years
- //-----------------------------------------------------------------------------
- System.out.println("I bet you didn't realize that in the next " + years + " years\n"
- + "you could potentially spend a total of...\n"); //print some text with variable years
- hoursTotal = hoursTV * (365 * years); //calculate total hours in 10 years
- System.out.println("\n " + hoursTotal + " hours, or\n"); //print the total hours in 10 years
- daysTotal = hoursTotal / 24; //calculate total days in 10 years
- System.out.println(" " + daysTotal + " days, or\n"); //print the total days in 10 years
- yearsTotal = hoursTotal / 8760; //calculate total years in 10 years
- System.out.println(" " + yearsTotal + " years watching TV!\n"); //print the total years in 10 years
- System.out.println("That's eye opening isn't it, " + name + "?!\n"); //print some text with their name
- System.out.println("********************************************************\n");
- } //end main
- } //end Project1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement