Newmultiply.Java
// NewMultiply.java - This program prints the numbers 0 through
10 along
// with these values multiplied by 2 and by 10.
// Input: None.
// Output: Prints the numbers 0 through 10 along with their values
multiplied by 2 and by 10.
public class NewMultiply
{
public static void main(String args[])
{
String head1 = "Number: ";
String head2 = "Multiplied by 2:
";
String head3 = "Multiplied by 10:
";
int numberCounter; //
Numbers 0 through 10.
int byTen;
// Stores the number multiplied by 10.
int byTwo; // Stores
the number multiplied by 2.
final int NUM_LOOPS = 10; //
Constant used to control loop.
// This is the work done in the
housekeeping() method
System.out.println("0 through 10
multiplied by 2 and by 10" + "\n");
// This is the work done in the
detailLoop() method
// Write for loop
// This is the work done in the
endOfJob() method
System.exit(0);
} // End of main() method.
} // End of NewMultiply class.
NOTE.
Please my teacher needs to see---- Screen Shot of the executed program showing that it worked ( a JPG or such file), and a SOURCE CODE (in a WORD doc or such) and a JAVA file, my source code, PROOF that my program compiles AND PROOF that it PRODUCES the proper OUTPUT. Please have the followingDISPLAYED WITHIN the SOURCE CODE file, near the top (so that he will see it when he print out the file).
My name Hamraj Selemani
class # 705
Lab # 5
PLEASE I NEED SCREEN SHOTS CONTAINING SOURCE CODE, MY NAME(Hamraj selemani), MY CLASS(705) & JAVA FILE.
While Loop
/*
Here I have initialised loop control variable with 1.
because initializing it to 0 will lead to an infinite loop
execution
because 0*2*10=0
so loop will never stop.
*/
public class NewMultiply {
public static void main(String a[]){
int loopController=1; //loop
control variable
while(loopController<10){
loopController=loopController*2*10;
}
System.out.println("Loop control
variable: "+loopController);
}
}
For Loop
public class NewMultiply {
public static void main(String a[]){
int ans=0;
for(int
loopController=0;loopController<10;loopController++){
loopController=loopController*2*10;
ans=loopController;
}
System.out.println("Loop control
variable: "+ans);
}
}
Output:
Newmultiply.Java // NewMultiply.java - This program prints the numbers 0 through 10 along // with these...
Summary In this lab the completed program should print the numbers 0 through 10, along with their values multiplied by 2 and by 10. You should accomplish this using a for loop instead of a counter-controlled while loop. Instructions Write a for loop that uses the loop control variable to take on the values 0 through 10. In the body of the loop, multiply the value of the loop control variable by 2 and by 10. Execute the program and...
Can someone help me with this Python code Summary In this lab, you work with the same Python program you worked with in Labs 5-1 and 5-3. As in those earlier labs, the completed program should print the numbers 0 through 10, along with their values multiplied by 2 and by 10. However, in this lab you should accomplish this using a while loop with a break statement. Instructions Make sure that the file NewestMultiply.py is selected and open. Write...
In this lab, you complete a partially written Java program that includes two methods that require a single parameter. The program continuously prompts the user for an integer until the user enters 0. The program then passes the value to a method that computes the sum of all the whole numbers from 1 up to and including the entered number. Next, the program passes the value to another method that computes the product of all the whole numbers up to...
In this lab, you complete a partially written Java program that includes two methods that require a single parameter. The program continuously prompts the user for an integer until the user enters 0. The program then passes the value to a method that computes the sum of all the whole numbers from 1 up to and including the entered number. Next, the program passes the value to another method that computes the product of all the whole numbers up to...
In this lab, you complete a partially written Java program that includes methods that require multiple parameters (arguments). The program prompts the user for two numeric values. Both values should be passed to methods named calculateSum(), calculateDifference(), and calculateProduct(). The methods compute the sum of the two values, the difference between the two values, and the product of the two values. Each method should perform the appropriate computation and display the results. The source code file provided for this lab...
JAVA HELP: Directions Write a program that will create an array of random numbers and output the values. Then output the values in the array backwards. Here is my code, I am having a problem with the second method. import java.util.Scanner; import java.util.Random; public class ArrayBackwards { public static void main(String[] args) { genrate(); print(); } public static void generate() { Scanner scanner = new Scanner(System.in); System.out.println("Seed:"); int seed = scanner.nextInt(); System.out.println("Length"); int length = scanner.nextInt(); Random random...
Write a program that will check a Java file for syntax errors. The program will ask for an input-file name and output-file name and will then copy all the code from the Java input file to the Java output file, but with the following changes: 1. Any syntax error found in the Java input file will be corrected: a. Missing semicolon b. Missing compound statements (curly braces) c. All comments have to start with // and end with a period....
4.3Learning Objective: To read and write text files. Instructions: This is complete program with one Java source code file named H01_43.java (your main class is named H01_43). Problem: Write a program that prompts the user for the name of a Java source code file (you may assume the file contains Java source code and has a .java filename extension; we will not test your program on non-Java source code files). The program shall read the source code file and output...
1) Consider the following Java program: 1 public class HelloWorld { 2 // My first program! 3 public static void main(String[] args) { 4 System.out.println("Hello, World!"); 5 } 6 } What is on line 1? a. a variable declaration b. a statement c. a method (subroutine) definition d. a comment e. a class definition 2) Which one of the following does NOT describe an array? a. It can be used in a for-each loop. b. It has a numbered sequence...