Write a for loop that computes the sum of all integers

Assignment Help JAVA Programming
Reference no: EM13879275

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

Reference no: EM13879275

Questions Cloud

Adonis industries changed its method of valuing inventory : 1.In 2013, Adonis Industries changed its method of valuing inventory from the average cost method to the FIFO method.
Case- iams and eukanuba understand people who love pets : Case- Iams and Eukanuba Understand people who love Pets. Why would consumers continue spending on their pets even during an economic downturn? Explain your answer in terms of consumes baying behavior concepts\
Prepare a production cost report for the month ended march : Aromatic Company for its line of perfume products for the month ended March 3. Prepare a production cost report for the month ended March 31, using the average cost method.
Determine the ratio uo-umax : Water flows steadily through the round pipe in the figure. The entrance velocity is Vo. The exit velocity approximates turbulent flow, u = umax(1 - r/R) 1/7. Determine the ratio Uo/umax for this incompressible flow.
Write a for loop that computes the sum of all integers : Write a for loop that computes the sum of all integers from 1 to 10
Reference validation mechanism and toe security functions : What are the conceptual differences between a reference validation mechanism, a trusted computing base, and the TOE Security Functions and How will you explain to the management of this company why their software is not a high assurance software.
Briefly describe the steps j j should take to report : Briefly describe the steps J J should take to report the change
What is the tax treatment of the scholarship : What is the tax treatment of the scholarship? Is Andrew required to include it as income on his tax return? Is Andrew eligible for the education credits?
Determine the total pressure drop : The mercury manometer reads a 6-in height. The pressure drop p2 - p1 is partly due to friction and partly due to gravity. Determine the total pressure drop and also the part due to friction only. Which part does the manometer read? Why?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd