0% found this document useful (0 votes)
52 views2 pages

Lorenzo Sukhdeo September 27, 2013 CS 115-01 Jessi

This document contains the code for several Java programs written by Lorenzo Sukhdeo for their CS 115 class. It includes programs that use for loops to print "Hello" multiple times based on user input, a program to calculate the average of doubles entered by the user in a for loop, and a program to find the minimum value among integers entered by the user in a for loop by comparing each value to an initialized variable n.

Uploaded by

Yong Jin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views2 pages

Lorenzo Sukhdeo September 27, 2013 CS 115-01 Jessi

This document contains the code for several Java programs written by Lorenzo Sukhdeo for their CS 115 class. It includes programs that use for loops to print "Hello" multiple times based on user input, a program to calculate the average of doubles entered by the user in a for loop, and a program to find the minimum value among integers entered by the user in a for loop by comparing each value to an initialized variable n.

Uploaded by

Yong Jin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Lorenzo Sukhdeo

September 27, 2013


CS 115-01
Jessi
Lab 5
5.
Enter an int >
Hello
Enter an int >
Hello
Enter an int >

6.
Hello
Enter an int >
Hello
Enter an int >
Hello
Enter an int >

7.
Enter an int >
Enter an int >
Hello
Enter an int >
Hello

8. i=10 and sum = 34

30. infinite loop.

32. there is a semicolon after the parenthesis of the for statement. Delete that semicolon!

33. infinite loop. this loop will keep going because it won’t stop because 10 and any number greater
than 10 will always be greater than 0. You should change 10 to 19, then the loop will fall out whenever i
is 19 or greater! Because we only want hello printed 10 times.

45.
import java.util.Scanner;
public class MyProgram
{
public static void main (String[] args)
{
Scanner scan = new Scanner( System.in);
System.out.print("Enter how many doubles how many wanted: ");
double i = scan.nextDouble();
double c= 0;

for (int z=1; z<=i; z++)


{
Lorenzo Sukhdeo
September 27, 2013
CS 115-01
Jessi
System.out.print("Enter a double: ");
double m= scan.nextDouble();
c= m+c;

}
System.out.println("The average value is: " + (c/i));
}
}

49.
import java.util.Scanner;
public class HelloWorld
{
public static void main (String[] args)
{
Scanner scan = new Scanner( System.in);
System.out.println("Enter a number as a integer");
int n = scan.nextInt();

for(int i=0; i<n; i++)


System.out.println("Hello World");
}
}

52.
import java.util.Scanner;
public class MyProgram
{
public static void main (String[] args)
{
Scanner scan = new Scanner( System.in);
System.out.print("Enter an integer: ");
int n = scan.nextInt();

for (int i=0; i<9; i++)


{
System.out.print("Enter an integer: ");
int m= scan.nextInt();

if (m<n)
n=m;

}
System.out.println("The minumum value is: " + n);
}
}

You might also like