Sum of the digit problem
the statement
int n = (int)Math.floor(Math.random()*100000 + 1);
randomly generate a 5 -digit number.
I need to write the code , which ramdomly generate a 5-digit number (using the above statement) and prints the sum of the digit s. Make sure the program print the number generated.
Example output:
Number generated:6743
sum of digits = 23
Thnaks for your respond. However , the code should be
base on the statement below.
int n = (int)Math.floor(Math.random()*100000 + 1);And you're not able to fit that in with the answer that the other guy handed you?
I need to write the code , Yes, you do.
which ramdomly generate a
5-digit number (using the above statement) and prints
the sum of the digit s.Your teacher gave you the code to generate the random number. That guy gave you the code to add the digits. What's left that you don't understand?
Similar Messages
-
Issue in Sum-of the years digit Depreciation
Hi,
I am capitalizing an asset in the mid of a year. Fiscal year of the company code is Jan -Dec ( Calendar Year).
Suppose my depreciation start date is Nov 1st 2010, which means 2 months will be depreciated in 2010 and 10 months in 2011 with the same depreciation rate. While depreciating the asset through Sum-of the years digit depreciation key
However, I am not getting the expected result.
The asset is depreciated for the 2 months and after that the asset is depreciated completely for 2011 with a new rate.
I am confused as to why this problem is arising.
Kindly help.Hi,
When I go to asset explorer, the depreciation calculation is
For 2010
Base value:230000
Percentage : 0.5000
Period : 2/12
Depreciation : 19166.67
For 2011
Base value: 230000
Percentage: 0.47222
Period: 12/12
amount : 108611.11
For 2011 it shd hv been:
Base value : 230000
Percentage: 0.50000
period : 10/12
amount : 95833.38
Base value : 230000
Percentage: 0.055555556
period : 2/12
amount : 12777.78
Kindly advice... how to bring this split up in 2011 -
Sum of the year digit method and declining balance method
Hi,
My Client want Deprecation methods Sum of the year digit and declining balance method for tax purpose. This requirement for Colombia Country.
Which Deprecation Area I activate and how will configure above two methods.
Regards
VenkiSum-of-the-Years-Digits Method of Depreciation
Use
For each year of the expected useful life, the system notes the remaining useful life for the assets and totals the figures in each year. In each fiscal year, the remaining life is divided by this total in order to calculate the depreciation percentage rate for that fiscal year. This method leads to depreciation amounts that are reduced progressively by the same amount each period.
Since the remaining useful life is no longer defined after the end of the planned useful life, this depreciation method does not allow for depreciation after the end of the planned life. However, you can change to another method after the expected useful life has expired.
Acquisitions after the depreciation start year or post-capitalization will necessarily lead to a positive net book value at the end of planned life. For this reason, such transactions are not allowed when using the sum-of-the-years-digits method of depreciation. With this method, you have to handle subsequent acquisitions by creating sub-numbers. It is also a requirement that the acquisition year is the same as the depreciation start year.
Calculation :
Depreciation = APC * remaining useful life (current period) / total of remaining useful life (over entire useful life)
APC: 1000
useful life: 4
Total remaining useful life: 10 (= 4 + 3 +2 +1)
Depreciation 1st year = 1000 * 4 / 10 = 400
Depreciation 2nd year = 1000 * 3 / 10 = 300
Depreciation 3rd year = 1000 * 2 / 10 = 200
Depreciation 4th year = 1000 * 1 / 10 = 100
Declining-Balance Method of Depreciation
Use
For the declining-balance method of depreciation, the fixed asset is depreciated by a progressively falling rate. A constant percentage rate is calculated from the expected useful life and a given multiplication factor. This is multiplied with the falling net book value of the fixed asset. For mathematical reasons, the net book value will never reach zero using this method. You change over to straight-line or complete depreciation under these conditions:
Declining-balance depreciation < straight-line depreciation
Net book value < x percent of acquisition value
Net book value < fixed amount
Net book value < straight-line depreciation
The changeover method is specified in the internal calculation key.
Calculation :
Depreciation = net book value * percentage rate from expected useful life and factor
APC: 1000
Exp. useful life: 10
Net book value: 700
Multiplication factor: 3
Depreciation = 700 * (100% / 10 * 3) = 210
OR You can use following link
http://help.sap.com/saphelp_45b/helpdata/en/4f/71de3b448011d189f00000e81ddfac/frameset.htm
http://help.sap.com/saphelp_45b/helpdata/en/4f/71de3b448011d189f00000e81ddfac/frameset.htm
Regards,
ANJIREDDY
Edited by: ANJIREDDYA on May 8, 2010 12:09 PM
Edited by: ANJIREDDYA on May 8, 2010 12:10 PM -
This is to sum up the problem. Here are facts :
This is to sum up the problem. Here are facts :
1. Java process size grows to ~ 3G and eventually exhaust native memory. Only
data segment of the process grows in size.
2. Java heap size remains stable, way under the max size. Perm generation
size is stable, way under the max size.
Here is a table showing evolution of Java process Virtual Memory
Start Monitoroing Java exited with OutOfMem
VmSize: 2764108 kB VmSize: 3094912 kB
VmLck: 0 kB VmLck: 0 kB
VmRSS: 1737364 kB VmRSS: 2020136 kB
VmData: 2461448 kB => VmData: 2792252 kB
VmStk: 216 kB VmStk: 216 kB
VmExe: 56 kB VmExe: 56 kB
VmLib: 301488 kB VmLib: 301488 kB
Plase note that Exe, Stack and Libs are the same at the beginning and the endof the period. Data segment increased for about 0.4G. The memory leak takes place in the native code.
Here is our log
05/08/13 07:38:10 java.lang.OutOfMemoryError: unable to create new nativethread
05/08/13 07:38:10 at java.lang.Thread.start(Native Method)
05/08/13 07:38:10 at com.evermind.util.ReleasableResourcePooledExecutor.addThread(ReleasableResourcePooledExecutor.java:121)
05/08/13 07:38:10 at EDU.oswego.cs.dl.util.concurrent.PooledExecutor.execute(PooledExecutor.java:978)
05/08/13 07:38:10 at com.evermind.util.ThreadPool.launch(ThreadPool.java:255)
05/08/13 07:38:10 at om.evermind.server.http.AJPConnectionListener.run(AJPConnectionListener.java:74)
05/08/13 07:38:10 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
05/08/13 07:38:10 at java.lang.Thread.run(Thread.java:534)
Exception in thread "CompilerThread1" java.lang.OutOfMemoryError: requested 612052 bytes for Chunk::new. Out of swap space?100M doesn't seem too extreme ... I ran a test program that created 100 sleeping threads, and ps -l reported the process size as 77M. I don't know Linux well enough to know the threading model (I suspect it's LWP-per-thread, which means that ps -m will give correct output).
However, given what you've shown (heap doesn't grow, process map does, failure occurs in code that starts a new thread), it really seems that your problem has something to do with too many threads.
My first thought, since I've seen it before is that there may be fragmentation of the memory map, such that there's no available segment when the JVM tries to allocate the stack for a new thread. When I saw this problem, the JVM (1.3 Solaris) was using a pretty naive approach to mapping those blocks, such that a few long-lived threads would cause it to run out of space. This information is available in the /proc/maps directory (man proc for more info).
There could also be some limit to the number of threads you can create. I know that Solaris returns ENOMEM when it's unable to create a thread; not sure what Linux returns.
Finally, I'm going to suggest again that you put logging messages in the thread factory that you're giving to the pool. Since you control that code, it's an excellent way to watch what's really happening at the time you run out of memory. -
Problem with summing up the currency fields
The below is my code through which I cannot display hthe sum at the end for all the below fields please advice on the soln. Also srched in SDN the answers are bit ambigious/also tried.
gw_fieldcat-fieldname = 'WTGXXX'.
gw_fieldcat-datatype = 'CURR'.
* gw_fieldcat-cfieldname = 'WAERS'.
gw_fieldcat-tabname = 'gt_output'.
gw_fieldcat-seltext_l = 'Material(Transaction currency)'.
gw_fieldcat-no_zero = 'X'.
gw_fieldcat-do_sum = 'X'.
APPEND gw_fieldcat TO gt_fieldcat.
CLEAR gw_fieldcat.
gw_fieldcat-fieldname = 'WOGXXX'.
gw_fieldcat-datatype = 'CURR'.
* gw_fieldcat-cfieldname = 'WAERS'.
gw_fieldcat-tabname = 'gt_output'.
gw_fieldcat-seltext_l = 'Material(Object currency)'.
gw_fieldcat-no_zero = 'X'.
gw_fieldcat-do_sum = 'X'.
APPEND gw_fieldcat TO gt_fieldcat.
CLEAR gw_fieldcat.
gw_fieldcat-fieldname = 'WKGXXX'.
gw_fieldcat-datatype = 'CURR'.
* gw_fieldcat-cfieldname = 'WAERS'.
gw_fieldcat-tabname = 'gt_output'.
gw_fieldcat-seltext_l = 'Material(Controlling area currency)'.
gw_fieldcat-no_zero = 'X'.
gw_fieldcat-do_sum = 'X'.
APPEND gw_fieldcat TO gt_fieldcat.
CLEAR gw_fieldcat.
gw_fieldcat-fieldname = 'WTGXXX1'.
gw_fieldcat-datatype = 'CURR'.
* gw_fieldcat-cfieldname = 'WAERS'.
gw_fieldcat-tabname = 'gt_output'.
gw_fieldcat-seltext_l = 'Labour(Transaction currency)'.
gw_fieldcat-no_zero = 'X'.
gw_fieldcat-do_sum = 'X'.
APPEND gw_fieldcat TO gt_fieldcat.
CLEAR gw_fieldcat.
gw_fieldcat-fieldname = 'WOGXXX1'.
gw_fieldcat-datatype = 'CURR'.
* gw_fieldcat-cfieldname = 'WAERS'.
gw_fieldcat-tabname = 'gt_output'.
gw_fieldcat-seltext_l = 'Labour(Object currency)'.
gw_fieldcat-no_zero = 'X'.
gw_fieldcat-do_sum = 'X'.
APPEND gw_fieldcat TO gt_fieldcat.
CLEAR gw_fieldcat.
gw_fieldcat-fieldname = 'WKGXXX1'.
gw_fieldcat-datatype = 'CURR'.
* gw_fieldcat-cfieldname = 'WAERS'.
gw_fieldcat-tabname = 'gt_output'.
gw_fieldcat-seltext_l = 'Labour(Controlling area currency)'.
gw_fieldcat-no_zero = 'X'.
gw_fieldcat-do_sum = 'X'.
APPEND gw_fieldcat TO gt_fieldcat.
CLEAR gw_fieldcat.
gw_fieldcat-fieldname = 'TOTAL1'.
gw_fieldcat-datatype = 'CURR'.
* gw_fieldcat-cfieldname = 'WAERS'.
gw_fieldcat-tabname = 'gt_output'.
gw_fieldcat-seltext_l = 'Total(Transaction currency)'.
gw_fieldcat-no_zero = 'X'.
gw_fieldcat-do_sum = 'X'.
APPEND gw_fieldcat TO gt_fieldcat.
CLEAR gw_fieldcat.
gw_fieldcat-fieldname = 'TOTAL2'.
gw_fieldcat-datatype = 'CURR'.
* gw_fieldcat-cfieldname = 'WAERS'.
gw_fieldcat-tabname = 'gt_output'.
gw_fieldcat-seltext_l = 'Total(Object currency) '.
gw_fieldcat-no_zero = 'X'.
gw_fieldcat-do_sum = 'X'.
APPEND gw_fieldcat TO gt_fieldcat.
CLEAR gw_fieldcat.
gw_fieldcat-fieldname = 'TOTAL3'.
gw_fieldcat-datatype = 'CURR'.
* gw_fieldcat-cfieldname = 'WAERS'.
gw_fieldcat-tabname = 'gt_output'.
gw_fieldcat-seltext_l = 'Total(Controlling area currency)'.
gw_fieldcat-no_zero = 'X'.
gw_fieldcat-do_sum = 'X'.
APPEND gw_fieldcat TO gt_fieldcat.
CLEAR gw_fieldcat.
thanks in advance.Try passing datatype = 'DEC'.
-
Discoverer plus report does not sum up the column
Hi All,
I am running the discoverer report from discoverer plus (web version) and was
trying to use the sum function to sum the total amount of the report.
The sum function does not work and it only display Cell
Sum: (blank) with no actual data.
When i checked the report details some columns are calculated based on the columns which i want to sum up.
My query uses CASE function to calculate one of the columns.
I changed the aggregation behavior setting to "Show the sum of the calculated values from the contributing cells "
then also i'm not able see the totals.
Any ideas please share with me.
Thanks in advance,Hard to answer your question without seeing what you are trying to do. Issues like this are often better reported to Oracle support, where they can get a web sesison going and be able to see what you see on your computer. Would be helpful to illustrate exactly what your detail looks like and how you are trying to create your sum. There could be several possible issues that could cause your problem, so all I can do is speculate some. Are you trying to sum one column, or are you creating multiple totals (for multiple columns)? Do you have any rows in the column with a NULL value? NULL values will be a problem when trying to sum up a column. You would need to convert the NUll value to something else, probably a zero. That would be the first thing I would look at. Hope that helps a little bit.
John Dickey -
Ipod freezing itunes, the last problem in a long list
So ill start from the beginning with the problems ive had with my ipod...
The first problem i had started maybe 6 months ago. My ipod would just stop playing when it played certain songs. Everything else worked fine, it would just stop sometimes. Then in the last few months it stopped being able to connected to a computer. Whenever i would hook it up it would just automatically eject itself. I tried hooking it up to a freinds computer and for some reason when it was hooked up to his computer it worked fine. I decided to just do a restore at the point hoping to end all my problems. The restore went fine. I started putting music back on it and i started getting error messages. The computer said that my ipod was missing the file that would allow me to sync with the computer or something like that. I tried to restore it again and it didnt change anything. In the last couple days i tried to put music on the ipod again and now it wont show at all in itunes. The ipod says its connected but when plugged in itunes just freezes.
I dont know if it makes any difference but my computer is a mac, and the computer i was able to do the restore on runs vista.
Im totally out of ideas and im not sure what my options are from here. Any and all help would be awesome.
Thanks in advance everybody!I get exactly what your describing and I noticed we are using the same laptop!!
I did not notice originally as I've got an old 40gb click wheel, about 3/4 years old. The battery is not great so assumed it may have been that but even fully charged I'm getting no luck.
I also followed the 5 r's and all the other suggestions for Ipod in My compute but not in itunes but nothing has worked. I cannot get my laptop to recognised my ipod via Itunes but it see's it fine via My Computer.
Both the Ipod and Itunes work fine without each other, Ipod plays songs fine etc and Itunes downloads music from cd etc and still performs all the usual functions but nothing else works.
I'm desperate for help as I run every day and buy a new cd each week and at this rate I'm going to have to dig out my old CD player!
Also just a point of note I looked the price to get my Ipod serviced as I figured this may help but the price quoted from apple was £160+...you can get a new 30gb for less...talk about customer explotation!! -
Hi,
I am working on report . I want sum of the quantity of the line items at the end of material .
I am using AT END OF MATNR.Here i am getting problem when same material have different plants i want the closing quantity separate according to plant . AT END OF MATNR is triggering only when new material no came but i require when plant and material any one change .Can you please suggest me.
example
matnr plant openingqua grsqua closingqty
4000 1030 100 1000
4000 1030 2000
4000 1030 3000 7100
4000 1031 200 2000
4000 1031 5000 9000
4001 1030 100 1000
4001 1030 2000
4001 1030 3000 7100
4001 1031 200 2000
4001 1031 5000 9000
Like this i require in o/p .
Regards
NandanHi,
In my report we have only one company code and 3780 material with plant 1030 1031 1010 .
I require some all line items qunatities according materialno and plant .
example
materialno1 and plant1
materialno1 and plant2
materialno1 and plant3
materialno2 and plant1
materialno2 and plant2
materialno2 and plant3
Regards
Nandan -
Guys, my browser is going crazy and every website that I am on changes in about 10 seconds to 2 minutes to another webpage. I even downloaded a newer 5.0 version of firefox and I am having the same problem.
Your System Details are showing Fun Web Products. Suggest you look in Add-ons - Extensions and Plug-ins, and Control Panel>Add/Remove programs or >(newer version) Programs and Features. You could also do a search of your computer.
Fun Web Products(associated with MyWebSearch) always seems to cause problems, Alexa does, too, but less often - there may be conflicts.
I'm not an expert on these two products. I'm afraid I can only alert you to the problems. Google will show you plenty of evidence of problems. You might also try the Search Firefox Help box above - a gold mine but it usually requires a lot of digging.
You can start Firefox in Safe Mode - Hold Shift Key down as you double click on the Firefox icon>ignore the page that opens>Continue. If that improves things you could do a little troubleshooting(Safe Mode, Problematic extensions etc), use default theme, -
https://support.mozilla.com/en-US/kb/Troubleshooting%20extensions%20and%20themes
http://support.mozilla.com/en-US/kb/Troubleshooting%20plugins -
The cumulative balance displayed in FS10N does not match the sum of the det
Hello,
The cumulative balance displayed in FS10N does not match the sum of the details. For example, we have a GL disbursement account that has a ***. Balance of 8 million. The debit is 2 million and the credit is 10 million. But, when you drill down on the ***. Bal. for the current period, the sum of the details is 9 million. According to our users, the 2 balances should equal. I did a search in this forum and found 1 post stating they had the same issue and the answer was to run f.16. Has anyone experienced this and if so, how did you handle it? I'm not sure how f.16 functions. Do we have to run it for each consecutive year? I'm not a FI specialist. I'm responsible for data archiving and the users think it's related to archiving. However, we have a test system that was resynced with production prior to when archiving was done and it shows that this issue is pre-existing.
Thank you very much in advance,
LourdesHello,
There is a possibility that you have activate line item display for some of the accounts at a later stage. Meaning that earlier postings were not be shown for the earlier postings but only totals will be made available. Therefore, obviously there is bound to be difference between line item report and totals report.
You need to identify which accounts are being changed with line item display at a later stage.
In case if you forget to keep GL Line item display for an account, but the posting are already made the following steps you would required to get the line item display retrospectively.
1. Note that you are NOT required to make the balance of that GL account to ZERO. Please do not confuse with Open Item Management.
2. Put the check box line item display for the account in FS00. Make sure you are entering right company code.
3. Block the account for posting in COA Segment and Company Code Segment in FS00
4. Go to SA38 and run program RFSEPA01 (Give correct GL Account and Company Code)
5. Now, remove the block you kept on the GL Account in FS00.
This will reset the line item display retrospectively.
Hope this will solve your problem.
Regards,
Ravi -
Can I use my plugins I bought at the Digi store in LE 8?
I'm leaving ProTools LE 7.4 for LE 8. Tired of the Digi hassle and problems with the mBox and my iMac. I have a bunch of plugins that I bought from the Digi store including Sans Amp, and some Joe Meek and Bomb Factory stuff which I like, but don't use a whole lot. They came in RTAS and AU format. I clean uninstalled PT, and that left the plug-ins on my iMac. Can I use them in LE 8? I have the licenses for all of them on my iLok for what that's worth. Thanks! I'm also using Apogee Ensemble now.
RickAs long as they are AU's, they should be usable in LE
Cheers,
Fox -
hello...we have some problem in summing out the results for the /BA1/K62EAD here based on the /BA1/C62UEXPOS. When we execute the program, the results always showing a few lines of the same /BA1/C62UEXPOS as below:
/BA1/C62UEXPOS /BA1/K62EAD
a 20
a 30
a 40
b 30
and the expected results should be a = 90 which is a sum but we got the results as below which break down to several records. what can we do on these? we have the code as below:
SELECT /BA1/C20BPART
/BA1/C62UEXPOS
/BA1/K62EAD
/BIC/OBJ_CURR
FROM /1BA/HM_8QZO_400 INTO wa_rdldata
FOR ALL ENTRIES IN i_resmort
WHERE /BA1/CR0GROUP = group_id AND
/BA1/C62UEXPOS NE i_resmort-t_mort_ftid_dum.
COLLECT wa_rdldata INTO i_rdldata.
SORT i_rdldata.
ENDSELECT.Hi,
try the code and revert back for any prob
SELECT /BA1/C20BPART
/BA1/C62UEXPOS
/BA1/K62EAD
/BIC/OBJ_CURR
FROM /1BA/HM_8QZO_400
INTO table i_rdldata
FOR ALL ENTRIES IN i_resmort
WHERE /BA1/CR0GROUP = group_id AND
/BA1/C62UEXPOS NE i_resmort-t_mort_ftid_dum.
loop at i_rdldata INTO wa_rdldata.
COLLECT wa_rdldata INTO i_rdldata.
endloop.
Regards,
Anirban -
With all the legit problems on this forum it is amazing that Logic Pro -
gets bought.
from recording delay to audio instrument faults.
score problems and time limitation in the arrange.
graphic issues to region snap problems.
apple loop limitations to au verifications or lack of
delay compensation to beta drivers and (what is this aggregated device mess)
list can go on....
man if Logic was an iLife app that would be sweet. <--- SARCASM
sorry everyone,
FPand what perspective is that?
tell me what perspective i should have? i'd like to know.
i didn't say i had a problem at the moment. i was just summing up the last couple weeks or so, and that is enough to make me curious about what else is out there, and how well it would fit into my workflow. really all i have ever messed with is Logic. so with that said, and all the "aparent" issues that are legit. it makes wonder if something else such as Nuendo would really kick some ***. i am waaaaaaaay out of pocket for macs and logic. i guess i will never know if others are better or not. doesn't matter.
it is crazy how i thought this was a forum for technical issues. thanks for confirming that. whew. i thought i was somewhere else. -
Finding Sum of the column whose column name is numeric value
HI All -
I have column names as years like 1990, 1991, 1992 and there are certain amount like below
*1990 1991 1992*
1000 5000 6000
2000 2000 3000
SUppose I want to find the sum of the amounts for year 1990, and I use the query like Select SUM(1990), it returns the sum of 1990+1990. How to make sure that 1990 is recognized as a column instead as a number.
ThanksHi,
To reference a column name that does not follow the normal rules (and starting with a digit does not follow the normal rules), then enclose the column name in double--quotes:
... SUM ("1990"), ...You can enclose any identifier in double-quotes, even ones that do follow the normal rules, but remember that anything inside any kind of quotes is case-sensitive.
If your query is assigning column aliases, like "1990", you might want to assign them only in the main query, after all references to them (like the SUM function you mentioned) have been done.
Depending on your front-end, you might get the same results by having the front end do the aliasing. For example, the SQL*Plus COLUMN command can assign an alias (like "1990") to a more gernerically named column (like year_1). Then you could use the noramlly named column throughout the query:
COLUMN year_1 HEADING "1990"
SELECT year_1
... SUM (year_1)
... -
Integrating a waveform to obtain a running sum of the amplitude
I am trying to decide the easiest way to integrate a waveform. I have obtained a signal and done a series of waveform operations on it, not I need to sum up the amplitudes of the waveform. I am assuming that the best way to do this is going to be using some sort of integration. I can't seem to get a simple integrator to do this.
Thanks for your helpHere is a little more information about the application. I have used data aquisitions to aquire two AC voltage waveforms. I have rectified the waveforms, and summed the two waveforms together. Now I need to take a summation (running sum) of the resulting waveform. Accuracy is somewhat of a concern, as this running sum will be used to calculate a series of costs and usage characteristics.
Hope this helps by giving an idea of what I am looking to do.
I have tried to do the numeric integration, but I am having a problem getting the waveform to sample as needed. My other idea was to convert the waveform to (x,y) coordinates and work with that data. I'm not sure what the best way will be.
Maybe you are looking for
-
How do I remove my credit card info from my account
How do I remove my credit card info from my account
-
It all started with a blank screen on a frozen iPhone. Doing the sleep and home button reset seemd to solve the problem, but then the apple logo started to show in the middle of calls, and finally, mail, camera, facebook and pulse apps failed to star
-
I was in the process of upgrading my iTunes software on to my Macbook Pro while at the same time checking youtube. My computer froze up and the only option I thought I had was to force quit. Now my iTunes has been affected and it wont work. A box wit
-
SQL*Plus logon attempt counter
Hi, I would like to use SQL*Plus to run some script agains DB. And I want to run it through script. So, I can set following parameters for sqlplus: logon and SQL-script name. But I have a problem how to check that this SQL has been run. For example D
-
Have a sealed copy of Adobe CS1 cannot activate
This copy of CS1 was never used. Says cannot activate. How do I activate this product?