VB icon

Sum of Numbers Using While Loop

Email
Submitted on: 7/25/2015 2:48:09 AM
By: Jake R. Pomperada  
Level: Beginner
User Rating: Unrated
Compatibility: Java (JDK 1.2), Java (JDK 1.3), Java (JDK 1.5)
Views: 3151
author picture
 
     A simple program that will sum up the series of number using while looping statement in Java. If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at my mobile number 09173084360. Thank you very much and Happy Programming.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Sum of Numbers Using While Loop
// Description:A simple program that will sum up the series of number using while looping statement in Java.
If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at my mobile number 09173084360.
Thank you very much and Happy Programming.
// By: Jake R. Pomperada
//**************************************

/*
while_loops.java
Programmer By: Mr. Jake R. Pomperada, MAED-IT
Date : July 21, 2015
Problem No. 1:
 
Design a program that calculates the sum of the input given
number of N using while loop statement.
*/
import java.util.Scanner;
class while_loops {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int sum=0,b=0;
System.out.print("\t Sum of Numbers Using While Loop");
System.out.println();
System.out.print("Enter your desired looping number : ");
int value = input.nextInt();
while (b<=value) {
 System.out.print(" " + b + " ");
sum+=b;
b++;
}
System.out.println();
System.out.println("The total sum is " + sum +".");
System.out.println();
System.out.println(" END OF PROGRAM"); 
System.out.println();
 }
}


Other 71 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.