Java Program - Introduction to Computer Programming | CS 0007, Assignments of Computer Science

Material Type: Assignment; Class: INTRO TO COMPUTER PROGRAMMING; Subject: Computer Science; University: University of Pittsburgh; Term: Fall 2005;

Typology: Assignments

Pre 2010

Uploaded on 09/02/2009

koofers-user-12s
koofers-user-12s 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Program 1 CS 0007 autumn 2005
Due: Tuesday, September 27, 2005
Write a Java program that will ask the user to enter a set of seven values from keyboard using the
methods of the tio class. The values are to be read entered into variables of various data types
that are in the following list.
1. An integer value to be stored in a variable of int type.
2. An integer value to be stored in a variable of short type.
3. An integer value to be stored in a variable of byte type.
4. An integer value to be stored in a variable of long type.
5. A fractional value to be stored in a variable of float type.
6. A fractional value to be stored in a variable of double type.
The user will enter a value between 30 and 100 for each of the first six numbers. Enter the same
value for each of the first six variables. For example, for the first time the program executes the
input command, enter the value 50 for each of these six numeric variables.
Next, after the values have been read, the program will print out the value of all six numeric
variables. Next the program will execute a loop 10 times and within the loop your program will
change the value of each variable to be twice as large as it currently is. So the program must
multiply the current value of the variable by 2 and set the value of the variable to this new value
for each pass through the loop. The new value of each variable along with a message describing
the type will be printed out for each pass through the loop.
An example is:
The int value is = 50
The short value is = 50
The byte value is = 50
The long value is = 50
The float …. < and it keeps going for float and double>
The int value is = 100 <the second time through the loop all 6 values are printed>
.
.
Execute the program at least six times and observe the values printed. Does each value double
for the variable for each pass through the loop? Alter the input values for each of the six runs,
input a value of 80 and later 100.
Your program must contain comments with your name, and program assignment number.
You need to copy the source file into the "handin" directory:
/afs/cs.pitt.edu/public/incoming/CS0007/fall2005c/hw1/
Instructions how to do this are on the webpage:
http://www.cs.pitt.edu/~michal/hp/ta2061-0007.php

Partial preview of the text

Download Java Program - Introduction to Computer Programming | CS 0007 and more Assignments Computer Science in PDF only on Docsity!

Program 1 CS 0007 autumn 2005 Due: Tuesday, September 27, 2005 Write a Java program that will ask the user to enter a set of seven values from keyboard using the methods of the tio class. The values are to be read entered into variables of various data types that are in the following list.

1. An integer value to be stored in a variable of int type.

2. An integer value to be stored in a variable of short type.

3. An integer value to be stored in a variable of byte type.

4. An integer value to be stored in a variable of long type.

5. A fractional value to be stored in a variable of float type.

6. A fractional value to be stored in a variable of double type.

The user will enter a value between 30 and 100 for each of the first six numbers. Enter the same value for each of the first six variables. For example, for the first time the program executes the input command, enter the value 50 for each of these six numeric variables. Next, after the values have been read, the program will print out the value of all six numeric variables. Next the program will execute a loop 10 times and within the loop your program will change the value of each variable to be twice as large as it currently is. So the program must multiply the current value of the variable by 2 and set the value of the variable to this new value for each pass through the loop. The new value of each variable along with a message describing the type will be printed out for each pass through the loop. An example is: The int value is = 50 The short value is = 50 The byte value is = 50 The long value is = 50 The float …. < and it keeps going for float and double> The int value is = 100 <the second time through the loop all 6 values are printed> . . Execute the program at least six times and observe the values printed. Does each value double for the variable for each pass through the loop? Alter the input values for each of the six runs, input a value of 80 and later 100. Your program must contain comments with your name, and program assignment number. You need to copy the source file into the "handin" directory: /afs/cs.pitt.edu/public/incoming/CS0007/fall2005c/hw1/ Instructions how to do this are on the webpage: http://www.cs.pitt.edu/~michal/hp/ta2061-0007.php