logo

Java Programming Assignment: Comma-Separated Integer Inputs and Exception Handling

   

Added on  2023-04-25

8 Pages937 Words481 Views
Running head: JAVA PROGRAMMING ASSIGNMENT
Java Programming Assignment
Name of the Student
Name of the University
Authors note
Java Programming Assignment: Comma-Separated Integer Inputs and Exception Handling_1
1JAVA PROGRAMMING ASSIGNMENT
Introduction
The program is developed in order to get input from the users as integers. In order
to take the input a separate method is declared and is called from the main method in the
program accompanied java program. The program also included the use of exception
handling using the try catch block. The integer inputs provided by the users is separated by
the comma and is displayed after calling the method from the main method.
Pseudocode
Declare getinput () method
Declare object of a scanner class
Declare “useDelimiter("\\D")” for specific delimiter in the program in order to take
comma separated input.
Declare int array[]
Initiate try catch block
For int i=0 to length of the array.
Assign values to the array
End of for loop
End of method
Start main
Call getinput ()
End of main
Java Programming Assignment: Comma-Separated Integer Inputs and Exception Handling_2
2JAVA PROGRAMMING ASSIGNMENT
Completed Program
package javaapplication;
import java.util.Scanner;
public class JavaApplication {
public static void getinput()
{
Scanner inp=new Scanner(System.in);
//Declaring object of scanner class
inp.useDelimiter("\\D");
int array[] = new int[3];
try {
for(int i=0;i<array.length;i++)
{
array[i]=inp.nextInt();
}
// j=inp.nextInt();
Java Programming Assignment: Comma-Separated Integer Inputs and Exception Handling_3

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
JAVA Program Using Array of Objects
|28
|2144
|15

Memory Sequence Game - Java Program for Console Based Game
|8
|998
|259

Java Programming | Assignment
|9
|834
|20

Introduction to Programming with Java - Solved Assignments
|12
|1129
|91

Major Steps for Solving the Problem
|2
|528
|11

CS4348 - Operating Systems Concepts
|5
|1324
|177