CSE-1020: Introduction to Computer Science I
York University
Labtest #1: Growth
2:30pm Thursday 01 October 2009
(Lab-03)
  Welcome to the Labtest Environment

During the test, you will not be able to access your regular home directory, access, receive, or send e-mail, print, or access the Internet.

At the end of your test session, this machine will be converted back to a standard, unrestricted Prism Lab machine. At this time, any files written by you during the test, except those that have been submitted, will not be recoverable. Make sure you submit your code before the end of the test . (Instructions to submit your code are below). If you do not submit your work on time, you will receive a grade of zero. (There are no exceptions).

Instructions

You have about 80 minutes to complete this test (regular lab time). The computers will automatically shutdown at the end of the lab (e.g., 3:50pm), warning you several minutes in advance. No additional time will be provided, so you must submit your work prior to this; otherwise, there will be no way to recover it (it will be lost), and you will receive a grade of zero (no exceptions).

You are encouraged to submit often during the test. Newer submissions overwrite older ones.

Submitting Your Work

When you submit a file, you must include at the top of the file your name (surname, given name) and your Prism lab login. These should be placed in a comment so that the file will compile. Note that files which do not compile will receive a large penalty when marked, no matter how small the error that prevented compiling.

Submit the class Growth.java before the time deadline. Here is the command to submit your work:

% submit 1020 labtest1R2.30 Growth.java

Note that in labtest1 above, the '1' is the character one, not the letter 'L'. Further details regarding the submit command can also be obtained by typing man submit.

Once again, you are encouraged to submit regularly. Newer submissions simply overwrite older ones.

Unlike eCheck assignments, there is partial credit possible. Even if you are unable to finish all aspects of the program, you should still check it in.

Useful APIs

Here are the common APIs that you may access:

Template Java Program

/* Name
 * CSE Account #
*/

import java.io.PrintStream;
import java.util.Scanner;

public class Template
{
    public static void main(String[] args)
    {
        PrintStream output = System.out;
        Scanner input = new Scanner(System.in);

    }
}
	

 
  The Task

Write a Java application called Growth.java that calculates the number of transistors (switches) on a microchip according to Moore's Law. It should prompt for, and then read in, at the console two numbers:

  • T, a real number, an amount of time in years
  • D, a real number, the amount of time in years required for the number of transistors to double

Moore's Law states that the number of transistors that can be placed inexpensively on a microchip doubles after a regular period of time. Mathematically, it can be expressed as:

N = 2000 * 2T/D

where N is the number of transistors, T is an amount of time in years, and D is the amount of time needed for the number of transistors to double; the number 2000 is approximately the number of transistors that could inexpensively be placed on a microchip 40 years ago.

Your program should output the number of transistors two different ways. The first way should be the number rounded to the nearest integer value. The second way should be the number rounded to the nearest thousand.

Sample Runs

Here are two sample runs of a correctly written program.

% java Growth
Enter the time in years : 40.0
Enter the doubling time in years : 2.0
2097152000 transistors
2097152 thousands of transistors
% java Growth
Enter the time in years : 40
Enter the doubling time in years : 1.95001
2992075853 transistors
2992076 thousands of transistors
%

Coding

You should use good programming practices as described in the textbook, and your code should conform to the style guide in the textbook. You should comment at least minimally, as by the guidelines.

You should not use any features of Java not covered in the first three chapters of the text; in particular, do not use if-statements or loops. There will be some deduction if you do.