Ans 4
the output will be
1 tiumes 1 followed by a new line
2 times 2 followed by a new line
3 times 3 followed by a new line
4 times 4 followed by a new line
5 times 5 followed by a new line
Explanation :- The print statement in the inner loop depend on the value of i of the outer loop. The inner loop will iterate until the value of i, which is incremented in the outer loop.
So for ,
1 st iteration value of i = 1 so inner loop will iterate 1 time and print the value of i and comes out of the inner loop and print the new line on the outer loop.
2nd iteration value of i = 2 so inner loop will iterate 2 time and print the value of i twice and comes out of the inner loop and print the new line on the outer loop.
Same logic follows untill the valkue of i is more than 5. When the value of i is more than 5 it comes out of the outer loop and hence the program execution is over.
Output Screen shot

-----------------------------------------------------------------------------------------------------------------------------
Ans 5
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
// Using Scanner for Getting Input
from User
Scanner in = new Scanner(System.in);
System.out.println("Enter any number");
int a = in.nextInt();
if(a % 2 == 0){
System.out.println("The entered number is Even");
} else {
System.out.println("The entered number is Odd");
}
}
}
Output

--------------------------------------------------------------------------------------------------------------------------------------------------
Ans 6
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
// Using Scanner for Getting Input
from User
Scanner in = new Scanner(System.in);
System.out.println("Enter Number scored in Exam");
int a = in.nextInt();
if(a >= 60){
System.out.println("Pass");
} else {
System.out.println("Fail");
}
}
}
output

(Fs ) -2 3-2 out prito Qu.5 Write a java program that will accept any mumber...
.Need code for my java class !! Write a simple java program that uses loops. You may use ‘WHILE’ or ‘FOR’ or ‘DO-WHILE’ – you decide. The program should use a loop to compute the semester average for up to 5 students. In the loop the user will ask for a student name and their 3 test scores and add them up and divide the total by 3 giving the semester average. You will print out the student name and...
This Java program reads an integer from a keyboard and prints it out with other comments. Modify the comments at the top of the program to reflect your personal information. Submit Assignment1.java for Assignment #1 using Gradescope->Assignemnt1 on canvas.asu.edu site. You will see that the program has a problem with our submission. Your program is tested with 4 testcases (4 sets of input and output files). In order to pass all test cases, your program needs to produce the same...
For this lab you will write a Java program that plays the dice game High-Low. In this game a player places a bet on whether the sum of two dice will come up High (totaling 8 or higher), Low (totaling 6 or less) or Sevens (totaling exactly 7). If the player wins, they receive a payout based on the schedule given in the table below: Choice Payout ------ ------ High 1 x Wager Low 1 x Wager Sevens 4 x...
Project: Using Java API Classes Page 3 of 5 SpaceTicket.java Requirements: The purpose of this program is accept coded space ticket information as input that includes the ticket price, category, time, date, and seat, followed by the description of the travel. Note that the eight digits for price have an implied decimal point. The program should then print the ticket information including the actual cost, which is the price with discount applied as appropriate: 25% for a student ticket (s),...
java create java program that make stack with LinkedList and stack is implement iterator. When stack’s iterator call next(), it pop its data. here is the example of output //by user 5 1 2 3 4 5 //then output comes like this 5 4 3 2 1 Stack is empty. here is the code that i'm going to use class Stack<T> implements Iterator<T> { LinkedList<T> list; public Stack() { list = new LinkedList<T>(); } public boolean isEmpty() { return list.isEmpty(); ...
( Object array + input) Write a Java program to meet the following requirements: 1. Define a class called Student which contains: 1.1 data fields: a. An integer data field contains student id b. Two String data fields named firstname and lastname c. A String data field contains student’s email address 1.2 methods: a. A no-arg constructor that will create a default student object. b. A constructor that creates a student with the specified student id, firstname, lastname and email_address...
(2 bookmarks) In JAVA You have been asked to write a program that can manage candidates for an upcoming election. This program needs to allow the user to enter candidates and then record votes as they come in and then calculate results and determine the winner. This program will have three classes: Candidate, Results and ElectionApp Candidate Class: This class records the information for each candidate that is running for office. Instance variables: first name last name office they are...
Java Program Note: no break statements or switch staements High, Low, Sevens For this lab you will write a Java program that plays the dice game High-Low. In this game a player places a bet on whether the sum of two dice will come up High (totaling 8 or higher), Low (totaling 6 or less) or Sevens (totaling exactly 7). If the player wins, they receive a payout based on the schedule given in the table below: Choice Payout ------...
Please write it in Java language
2. (Myinterface.java) The program description below was found waaaaay back in the archives of the Equinox history database. It is the specification for a simply "computer store storefront". Even though computer stores are now extinct, you find the idea charming and decide to use the specification as inspiration to write an interface for one of the Equinox systems. Read carefully: write your own GUI for one of the Equinox systems, drawing inspiration from the...
For this lab you will write a Java program that plays a simple Guess The Word game. The program will prompt the user to enter the name of a file containing a list of words. These words mustbe stored in an ArrayList, and the program will not know how many words are in the file before it starts putting them in the list. When all of the words have been read from the file, the program randomly chooses one word...