notes102506 - /scope int n/available global for(n=0 for(int...

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

Sheet1 Page 1 //scope int n //available global for(n=0, ......... ) for(int n ........ ) //available only for for loop //multiple initializations in loop int n,m for(n=0,m=5 ... ...){} OR for((n=0) && (m=0) ... ...){}//another way //////////////////////////////////////////// Code4-9 - Sentinel (escape) //////////////////////////////////////////// int sum=0 while(i != -1){ sum+= i System.out.println("Enter next Sale") } //////////////////////////////////////////// Nested loops //////////////////////////////////////////// for(h=0 h<24 h++){ for(m=0 m<60 m++){ for(s=0 s<60 s++){ System.out.println(h+":"+m+":"+s) } } } //////////////////////////////////////////
Image of page 1

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

Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: import* Output to a file Filewriter fw = new FileWriter("data.txt") //opens a file PrintWriter pw = new PrintWriter(fx) //connects to FileWriter pw.println("it is Wednesday!") pw.close() ////////////////////////////////////////// input from a file FileReader fr = new FileReader("data.txt") //open existing file BufferedReader br = new BufferedReader(fr) String s = br.readLine() //reads 1st line in data.txt Sheet1 Page 2 while(s != null){ //null means end of file (eof) System.out.println(s) s = br.readLine() } br.close()...
View Full Document

  • Winter '06
  • Kerbs
  • loop, int sum=0, ......), int n,m, DATA.TXT, //null means end

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern