Lab 01

Short Assignment 01

Introduction

In today’s lab session we will practice using Scanner to take in user input from the keyboard and to read text files.

Given a text file that contains multiple lines with integers separated by space, your java application is to sum all integers and print out the result.

For example, for the following text file:

inputFile1.txt

3 3 3
50 40

Your application should print out 99.

For the file name to read, prompt the user to type a file name and read the keyboard entry. The message you should print to the user is Enter file name: – note the space after : and make sure to not print a line break after the space.

Example run:

Enter file name: inputFile1.txt
99

File setup

Add the package name to the top of your file, so gradescope can find the compiled binary file:

package com.gradescope.filesum;