{
public static void main(String[] args) { Scanner scan=new Scanner(System.in); System.out.println("Enter how many times you wish the message to be printed."); int limit = 0; 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("Printed this message " + limit + " times."); System.out.println("The sum of the numbers from 1 to "+limit+" is "+sum); }
}
import java.util.Scanner; public class PowersOf2
{
public static void main(String[]args)
{
int valuePowersOf2; int nextPowersOf2 =1; int exponent= 0; int count=0;
Scanner scan = new Scanner(System.in);
System.out.println("Enter A Number."); valuePowersOf2=scan.nextInt(); System.out.println(" First 8 "+valuePowersOf2+" powers of 2"); while(exponent<valuePowersOf2) {
System.out.println("2 ^ "+exponent+" = "+nextPowersOf2); while(count<=exponent) { nextPowersOf2*=2; count++;
}
exponent++;
}
}
}
// **********************************************************
// Temps.java
//
// This program reads in a sequence of hourly temperature
// readings (beginning with midnight) and prints the maximum
// temperature (along with the hour, on a 24-hour clock, it
// occurred) and the minimum temperature (along with the hour
// it occurred).
// **********************************************************
import java.util.Scanner;
public class Temps
{
//----------------------------------------------------
// Reads in a sequence of temperatures and finds the
// maximum and minimum read in.
//----------------------------------------------------
public static void main (String[] args)
{
final int HOURS_PER_DAY = 6;
int temp; //a temperature reading int maxTemp = -1000; //maximum temperature int miniTemp = 1000; //minimum