Ex6NeedObjects

Ex6NeedObjects - System.out.print(“Please enter student...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* UnwieldyClass * * This class demonstrates how classes can make code better organized. */ import java.util.Scanner; public class UnwieldyClass { public static void main(String args[]) { String studentName1, studentName2, studentName3; int studentPermNo1, studentPermNo2, studentPermNo3; String studentAddr1, studentAddr2, studentAddr3; String studentPhone1, studentPhone2, studentPhone3; // notice that we can declare and initialize on the same line! Scanner readInfo = new Scanner( System.in ); // now get the info System.out.print(“Please enter student name:”); studentName1 = readInfo.nextLine(); System.out.print(“Enter permanent number”); studentPermNo1 = readInfo.nextInt(); readInfo.nextLine(); System.out.print(“Enter address”); studentAddr1 = readInfo.nextLine(); System.out.print(“Enter phone number”); studentPhone1 = readInfo.nextLine();
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: System.out.print(“Please enter student name:”); studentName2 = readInfo.nextLine(); System.out.print(“Enter permanent number”); studentPermNo2 = readInfo.nextInt(); readInfo.nextLine(); System.out.print(“Enter address”); studentAddr2 = readInfo.nextLine(); System.out.print(“Enter phone number”); studentPhone2 = readInfo.nextLine(); System.out.print(“Please enter student name:”); studentName3 = readInfo.nextLine(); System.out.print(“Enter permanent number”); studentPermNo3 = readInfo.nextInt(); readInfo.nextLine(); System.out.print(“Enter address”); studentAddr3 = readInfo.nextLine(); System.out.print(“Enter phone number”); studentPhone3 = readInfo.nextLine(); …. and then the rest of our program here …. . } }...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

Ex6NeedObjects - System.out.print(“Please enter student...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online