CSCI 1011 – Lab 2
For this lab you will
compile, execute, test, and modify a simple Java program.
1.
Start NetBeans.
2.
Follow the instructions in Lab 1 to create a new
project called Lab 2.
3.
Follow the instructions in Lab 1 to create a new
java main class called yourlastnameLab2.java
except with your last name with csci1011.lab2 as the package
name.
4.
Write following program in the editor window
(with your actual name in the comments):
// <your name here>
// Sample program to double the value of a number
// CSCI 1011 Lab 2
import java.util.Scanner;
public class DanaLab2{
public static void main(String[] args)
{
int num, result;
Scanner kb=new
Scanner(System.in);
System.out.println(“Enter an
integer”);
num = kb.nextInt();
result = 2 * num;
System.out.println(“Twice the integer is ” + result);
}
}
5.
Run the program and test it with sample input.
Do this several times.
6.
Modify the program to input two numbers and
display the result of multiplying those two numbers.
7.
Run the program and test it with sample input.
8.
Modify the program to display both the result of
multiplying the two numbers and the result of adding the two numbers
9.
Run the program and test it with sample input.
10. Make
sure to change the description in the comments to reflect the changes that you
have made.
11. Upload
the file yourlastnameLab2.java
to the assignment folder labeled Lab 2.
Get Free Quote!
264 Experts Online