[Show all top banners]

jerrybhoot
Replies to this thread:

More by jerrybhoot
What people are reading
Subscribers
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 Java Help wanted
[VIEWED 4055 TIMES]
SAVE! for ease of future access.
Posted on 10-03-08 2:58 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Dear frens,

Can I get a Java application that finds the total and average of odd numbers from 1 to 15 which must use a counted loop.

Thanks in Advance.

jerry


 
Posted on 10-03-08 8:42 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

...and why is that difficult ?

int sum = 0;  // initilize sum to 0

// run thru the loop, 1 to 15 times, somehting like ( int i = 0; i<= 15; i++)
// now take the Mod of i , if its zero its even and if its 1 its odd.
// so add the every time mod i = 1;
// someting like if ( mod i = = 1)
    sum++; 

// end of loop, problem solved.


 

 
Posted on 10-03-08 11:26 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Try this one,

1) Initialize sum=0

2)Initialize counter=0

3)Initialize average=0

3)Get the sum from 1 to 15

for(int i=1; i<=15; i++)

{ sum=sum+i;

counter++;

}

4)Get average

average = sum/counter;

Good luck

 


 
Posted on 10-03-08 2:08 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

थिमियाम्ह प्रजापति ख:ला ?
 
Posted on 10-03-08 2:51 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Yeah, who is this CT ?
 
Posted on 10-03-08 4:20 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

ए!! west coast ए छम्ह निम्ह थिमिया प्रजापति किजापिं दु धैगु ला स्यू, झी गन थें ?

मोहनि नख:या भिन्तुना दु । कूछि भ्वय् बांलाक्क भपिया दिसँ न्है ।


 
Posted on 10-03-08 5:55 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

जी वेष्ट कोस्तए मखु , इष्ट कोस्त पाखे लतका  |
wish you Happy Vijaya Dashmi to u to..

 
Posted on 10-03-08 6:15 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Try this one,

1) Initialize sum=0

2)Initialize counter=0

3)Initialize average=0

3)Get the sum from 1 to 15

for(int i=1; i<=15; i=i+2)

{ sum=sum+i;

counter++;

}

4)Get average

average = sum/counter;

Good luck

  Alchi laagyo


 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 90 days
Recommended Popular Threads Controvertial Threads
डीभी परेन भने खुसि हुनु होस् ! अमेरिकामाधेरै का श्रीमती अर्कैसँग पोइला गएका छन् !
शीर्षक जे पनि हुन सक्छ।
What are your first memories of when Nepal Television Began?
Sajha Poll: नेपालका सबैभन्दा आकर्षक महिला को हुन्?
NRN card pros and cons?
Basnet or Basnyat ??
निगुरो थाहा छ ??
Nas and The Bokas: Coming to a Night Club near you
TPS Re-registration
अमेरिकामा छोरा हराएको सूचना
TPS Re-registration case still pending ..
Breathe in. Breathe out.
nrn citizenship
My facebook archive (for sale)
Top 10 Anti-vaxxers Who Got Owned by COVID
ढ्याउ गर्दा दसैँको खसी गनाउच
Sajha has turned into MAGATs nest
Doctors dying suddenly or unexpectedly since the rollout of COVID-19 vaccines
अमेरिकामा बस्ने प्राय जस्तो नेपालीहरु सबै मध्यम बर्गीय अथवा माथि (higher than middle class)
Send Parcels from USA to Nepal & Worldwide.
Nas and The Bokas: Coming to a Night Club near you
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters