Using the instructions from closed Lab 01, create a new folder named closedLabo6
ID: 3793522 • Letter: U
Question
Using the instructions from closed Lab 01, create a new folder named closedLabo6. For each of the following problems, you will need to reate a new Java with the name given in the problem description. Make sure that in the comments at the top of the java program put name and your partners name and today's date using the format for Java comments given in Closed Lab 01 Exercise 1 Description using a ncsted loop, your program should output a simple multiplication table to the screen. The table should In the ClosedLabo6 folder, create a new Java program named Labo6a.java this problem be computed up to 10 x 10. Exercise isample output This is a sample transcript of what your program should do. 10 2 14 20 18 30 28 40 45 50 28 63 70 16 40 72 81 40 50 NOTE: You must use a nested loop for this assingment. Think about using a loop to print a single row, and then a second loop to run that times. NOTE 2: Formatting is important. Make sure your code lines the right edge of each number up in the appropriate column. Exercise 2 DescriptionExplanation / Answer
Exercise 1:
// http://ideone.com/iHs7fV
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
for(int i=1;i<=10;i++){
for(int j=1;j<=10;j++){
System.out.printf(" %3d",i*j);
}
System.out.println("");
}
}
}
For output refer : http://ideone.com/iHs7fV
//http://ideone.com/50A31y
import java.util.*;
class Palindrome
{
public static void main(String args[])
{
String original, reverse = "";
Scanner in = new Scanner(System.in);
while(true) {
System.out.println("Enter a string :");
original = in.nextLine();
int length = original.length();
if (length == 0 ) {
System.out.println("Empty list read - Goodbye!");
break;
}
boolean pallindrome = true;
for ( int i = 0,j=length-1; i < length; i++,j-- ){
if (original.charAt(i) != original.charAt(j)) {
pallindrome = false;
break;
}
}
if (pallindrome)
System.out.println(original+" is a palindrome.");
else
System.out.println(original+" is NOT a palindrome.");
}
}
}
For output check : http://ideone.com/50A31y
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.