Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Q1. What is the output of the following code snippet

1.1

int i = 0;

while (i != 9)

{

System.out.println("" + i);

i = i + 2;

}

 

1.2.

int i;

int sum=0;

for(i=0; i<5;i++)

{

if(i>1)

sum=sum+i;

}

System.out.println("Sum is " + sum); System.out.println("last value of i is" + i);

Q2. 1 Convert the following for loop into a while loop and draw the flow chart.

int sum = 0;

for (int i = 10; i > 10; i--)

sum = sum + i


Q2.2 Write a for loop that computes the sum of all integers from 1 to 10.


Q3: Write complete Java programs, provide a screen snapshot showing your program in execution to receive full credit.


3.1 Generate the following output using any loop statement .

*
**
***
****
*****

3.2 In municipal elections office, voters are checked for eligibility and after registration they can vote. Write a program that asks the user about their name and age, and check if the voter is eligible to cast vote. (For eligibility age should be greater than 18)

Ask the user "do you want to take another voter details (Yes/No)" if the user presses Yes , take name and age again and check eligibility. Do it again until user presses No.

The following is a sample output when user enters Abdullah/23/Yes , Sarah/15/No.


Sample output:

Enter name: Abdullah

Enter Age :23

Abdullah can cast vote

Do you want to take another voter details (Yes/No) :Yes

Enter name :Sarah

Enter Age :15

Sarah cannot cast vote.

Do you want to take another voter details (Yes/No) : No

Java, Programming

  • Category:- Java
  • Reference No.:- M91547790
  • Price:- $25

Priced at Now at $25, Verified Solution

Have any Question?


Related Questions in Java

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As