LoveCS - "); limit = scan.nextInt(); int sum = 0; int...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// **************************************************************** // LoveCS.java // // Use a while loop to print many messages declaring your // passion for computer science // **************************************************************** import java.util.Scanner; public class LoveCS { public static void main(String[] args) { int limit; Scanner scan = new Scanner (System.in); System.out.print("Enter the number of times the message should be printed:
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: "); limit = scan.nextInt(); int sum = 0; int count = 1; while (count <= limit){ System.out.println(count + " I love Computer Science!!"); sum += count; count++; } System.out.println("Message was printed " + limit + " times."); System.out.println("The sum of the numbers from 1 to " + limit + " is " + sum + "."); } }...
View Full Document

This note was uploaded on 03/22/2010 for the course CS 202 taught by Professor Fong during the Spring '10 term at SIU Carbondale.

Ask a homework question - tutors are online