1 / 12

CSC1401 Input and Output (and we’ll do a bit more on class creation)

CSC1401 Input and Output (and we’ll do a bit more on class creation). Learning Goals. Computing concepts Input and output in Java Using the Scanner class. To date. We have been working with pictures, and with drawing, and with turtles

phoebe
Download Presentation

CSC1401 Input and Output (and we’ll do a bit more on class creation)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC1401Input and Output (and we’ll do a bit more on class creation)

  2. Learning Goals • Computing concepts • Input and output in Java • Using the Scanner class

  3. To date • We have been working with pictures, and with drawing, and with turtles • We have not really been getting any input from the user • Our output has mostly been limited to invoking show() or explore() on a picture

  4. This next week • We’ll be looking at textual programming –numbers and words (Strings), before going back to more graphical material after Thanksgiving • Needed in lots of computational areas

  5. Output in Java • System.out.print() • System.out.println() • Place what we want printed inside the () • Use + to concatenate things • System.out is an object (the standard output – the display on our computers)

  6. Input in Java • System.in is the standard input (the keyboard) • However, we need a special class, located in java.util.Scanner

  7. Syntactically import java.util.*; // needed for scanner class IOTesting { public static void main(String [] args) { Scanner scan = new Scanner(System.in); int value = scan.nextInt(); …

  8. Input • What else can you read in besides ints? • See the Javadoc • nextBoolean() • nextDouble() • nextFloat() • nextLine() reads in a String • etc.

  9. Problem solving with Input and Output • Keeping track of exam grades for CSC1401 • Then writing methods for: • Finding out the exam average • Printing out the grades • Calculating the standard deviation (if I remember how to do it) • Who got the highest grade? And what it was… • etc.

  10. ExamGrades class • What variables do we need? • What methods? • Building the class

  11. Summary • We use System.out for output to the terminal • We use System.in in conjunction with a Scanner object for getting input from the keyboard

  12. Reading Assignment • none

More Related