Introduction to Java using NetBeans

Section 2 - Console Input

 

Java Packages

Java includes packages that contain general use classes, utility classes, or special purpose classes. 

The import statement is used to make the members of a package accessible to an application. 

In this assignment you will need the Scanner Package

;

 

Built in String Methods

next() - returns a string from the input stream

nextLine() - returns the string up to the end of line character from the input stream

nextInt() - returns the int read from the input stream

nextDouble() - returns the double read from the input stream

nextBoolean() - returns the Boolean read from the input stream

close() - closes the input stream

 

 

 

 

 

Message Dialog Boxes

Changing The Message Box

In fact, there are variations for the showMessageDialog method that allow 2 more parameters so that you can change the title on the window as well as add a picture.  The format is:

JOptionPane.showMessageDialog(null,"Message","Title",JOptionPane.TYPE_MESSAGE);


JOptionPane.ERROR_MESSAGE
Use this when you want to tell the user that an error has occurred in the program.


JOptionPane.WARNING_MESSAGE
Use this when you want to warn the user about something in the program.


JOptionPane.INFORMATION_MESSAGE
Use this when you want to tell the user something in the program.


JOptionPane.PLAIN_MESSAGE
Use this when you do not want a picture.

 

 

Assignments

Assignments 2.1 - 2.6 - Modify Assignments 1.6 - 1.11 so that the user enters all required information
Display your results in a message box. (except bill of sale)

Make sure you have uploaded them to the S1 Section of you website before you modify

ICS4U only

Assignment 2.7 Calculations

Create an application that displays the product and sum after the user enters 5 numbers. Display the result in a message box.

 

 

Posting your work

1. Upload the Java Projects to your Gravelle Folder (Share with me only) and insert the Drive Folder (Insert > Drive Folder)

You do not need to submit code and screenshots as we will be combining these assignments in A 2.3