homework and midterm

Write a program that gets an integer from the user

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: pOut { public static void main(String args) { int i=4; int j=6; for(i=0;i<5;i++){ if( i > 2 ){ System.out.println("i= " + i); for(j=j; j<10; j++){ System.out.println("j= " + j); } } } } } Output: i= j= j= j= j= i= 3 6 7 8 9 4 5 24. Write the output of the following program in the space provided below: public class WhatOut{ public static void main(String args) { int i=4; char c='a'; for(i=9; i < 10; i++){ System.out.printf("%3d%3d%3d\n", i, i+1, i+2); c = (char)(60 + i); System.out.println( "--" + c + "--" + ++c + "--" + ++c); } } } Output: 9 10 11 --E--F--G you should try to line up the 9, 0, and 1 with E F and G respectively 6 25. Write a program that gets an integer from the user, and then prints “hello” (without the quotes) the number of times that the user enters, with each hello on a separate line. import java.util.Scanner; public class MyProgram{ public static void main(String args){ Scanner input = new Scanner(System.in); System.out.println(“This program prints hello the number of times yo...
View Full Document

This note was uploaded on 10/16/2011 for the course CSC 210 taught by Professor Staff during the Spring '11 term at S.F. State.

Ask a homework question - tutors are online