A Beginners Outcry: Homework of sum and Average

Dear all,
I am a java dummie. This is what happens intuitively in my mind. I need a program that runs to calculate the sum and average of either positive or negative inputed integers. The maximum input integers = 100. As defined, sn = sum of negative integers, sp = sum of positive, in = count of negative integers, ip = count of positive integers. If input integer = 0, the program comes to an end. If input integer is non zero, the outcomes would be sum of negative and sum of positive, average of negative and average of negative. I think I should use do-while statement, but..... Also, for the input, should I input a list of integers....Can someone show me the code plus some brief explanation that a beginner like me would be able to understand? Thanks.

yawmark wrote:
Can someone show me the code plus some brief explanation that a beginner like me would be able to understand?
[So, You Need to Write a Program but Don't Know How to Start|http://home.earthlink.net/~patricia_shanahan/beginner.html].
~Ta. I just read through that article again, and again I find myself in awe of the sageness of such simple advise... I'm bookmarking it, to reread whenever I feel like tearing my hair out over a problem.
Cheers. Keith.

Similar Messages

  • Sum and Average Group Wage instead of Details Wage

    I have a subreport where I have included all of our employment records and grouped it by employee ID. In the Group Footer, to show the latest employment record I used the Max(Start Date) and I have also placed the Hourly Wage field here which shows the appropriate Wage for the Max Date. But I can't seem to use the Sum or Average Summary because it Sums and Averages All Wages in the Details report vs. only the latest record.
    So, how do I Sum/Average the wages for only the last employment record Or how do I create the report to show only the Last Employment Record?
    I'm using Crystal XI. Any help will be greatly appreciated.
    Thanks

    Place the fields in group header instead of placing in details section using maximum() function. Now got to report>record sort expert>add start date field-->select descending order.
    Now the report shows latest date entries for each group.
    If you want to calcualte the sum then use mannual running totals like
    create a formula like
    @sum:
    whileprintingrecords;
    numbervar i;
    i:=i+{field}
    Now place this in group header and supress
    create another formula like
    @Total:
    whileprintingrecords;
    numbervar i;
    place this in report footer which gives grand total.
    Regards,
    Raghavendra

  • Sum and average of a list of integers

    heya all
    im trying Implement a program to find the sum and average of a list of integers terminated by the data marker -999.
    import java.util.*;
    public class sumaverage
       public static void main(String[] args)
    int sum = 0;     // input the first number
           int num = kybd.nextInt(); // kybd is an instance of Scanner
           while ( num != -999 )    // while the end of data not found
                sum += num ;
                num = kybd.nextInt(); // input the next number
           System.out.println("the sum is " + sum );
    }}Currently im getting " cant find symbol" on lines 10 + 16 pointing at the k in kybd.nextInt(); , could anyone tell me whats wrong as im lost ?
    Thankyou

    thanks mate , i cant belive i missed that :S
    im now trying to add the adverage to the code
    ive done the following coding , can anyone confirm this is correct ? it all compiles fine ...
    import java.util.*;
    public class sumaverage
       public static void main(String[] args)
         Scanner kybd = new Scanner(System.in);
         int sum = 0;     // input the first number
         int n;
         double Adverage = 0;
           int num = kybd.nextInt(); // kybd is an instance of Scanner
           while ( num != -999 )    // while the end of data not found
                sum += num ;
             n = kybd.nextInt();
                sum += n;
             Adverage = sum/n;
                num = kybd.nextInt(); // input the next number
           System.out.println("the sum is " + sum );
           System.out.println("The adverage of the integers is " + Adverage);
    }}

  • How to get two Results  - Sum and Average for one KeyFigure

    I have "Material" in Rows and "Cal Year/Month" in Columns and also KeyFigure "Qty" in Columns.
    The Results (Yellow) of "Qty" is defined as "Avg of all values <>0". This works fine but how do I get two Results - one is a "Sum" and the other "Avg" for just one KeyFigure. The output basically should look like below:
          Cal Yr/Month  01/2006   02/2006   03/2006...    Result        Result
    Material                   Qty       Qty           Qty       Sum of Qty   Avg of Qty
    ABC                       100         0             200            300             150     
    DEF                       100         200          300            600             200     
    GHI                        500         300          400           1200            400

    Hi Srinivas,
    I think you must use Restricted Key Figures and Formula.
    Do not introduce CALMONTH in columns, but restrict 12 times the Key Figure Qty with 0CALMONTH3, that is 01-02-03-...
    Then create a Formula that is the Sum of all Restricted KF and call it SUM.
    Then copy the previous Formula (SUM) and call it AVG and give the option of Average of all Values <>0.
    Try.
    Ciao.
    Riccardo.

  • BEx Query Formating - Displaying both Sum and Average in the same report

    Hi everybody,
    I need to create a BW report in the below format,
                          Company Code                                            Total       Total Average
                                   0001            0002      0003      0004
    Doc Type
        AV                        10               10         10         10            40                 10
        RV                        20               20         20         20            80                 20
    Getting the report till the 'Total' column is easy but having the 'Total Average' as a separate column is where I am stuck.
    Having the company code in the rows, and not clolumns, would have solved the issue but I need to keep the above format. Also I do not want to
    see the Total Average for every Company Code, just that of the 'Total'.
    In the Query Designer, in the Column section I have first the 'Company Code' and then the 'Count' in a structure, so whatever I add to this structure,
    is displayed for each Company Code, that means 2 columns for each Company code. This changes the format.
    I cannot use the Cell Definition method here, as then it would be a static structure and the number of Company Codes are not fixed.
    It would be great if somebody could provide some suggestions.
    Thank you,
    Ajay

    Hi Suman,
    Thanks for the quick reply.
    I have tried this, but again this will change the format. With the way you said, I will only get the report in the below 2 formats,
    1. Company code in Free Charac, later drill down to Rows,
    Doc Type  Company Code  
        AV                 0001                10
        AV                 0002                10
        AV                 0003                10
        AV                 0004                10
        Total                                      40
        RV                 0001                20
        RV                 0002                20
        RV                 0003                20
        RV                 0004                20
        Total                                      80
    or 2. Company code in Free Charac, later drill down to Column,
                      Company Code                                       
                               0001                     0002                     0003                     0004    
                        Total    Total Avg   Total   Total Avg   Total   Total Avg  Total   Total Avg
    Doc Type
        AV             10           10             10         10           10         10           10           10
        RV             20           20             20         20           20         20           20           20
    Both the above are different from the format that I need.

  • Moving sums and averages - it is possible - any ideas??

    Customer wants a report with these conditions (values are entered by user at run time):
    * Start time - for example 2008/01/01 00:00 + (no problem, filter on time dimension) +
    * Stop time - for example 2008/01/31 23:59 + (no problem, filter on time dimension) +
    * Window size for examples: 1 day ; 3 days; 1 hour; 5 minutes
    * Step size for examples: 2 day ; 3 days; 1 hour; 15 minutes
    * Measures are agregated for every line by Windows size
    This mean that report looks like:
    "start time"                            MSUM(Measure1,"window size")           MAVG(Measure2,"window size")        MMAX(Measure1,"window size")
    "start time" + 1*"step size"              MSUM(Measure1,"window size")           MAVG(Measure2,"window size")        MMAX(Measure1,"window size")
    "start time" + 2*"step size"              MSUM(Measure1,"window size")           MAVG(Measure2,"window size")        MMAX(Measure1,"window size")
    "start time" + 3*"step size"              MSUM(Measure1,"window size")           MAVG(Measure2,"window size")        MMAX(Measure1,"window size")
    "start time" + 4*"step size"              MSUM(Measure1,"window size")           MAVG(Measure2,"window size")        MMAX(Measure1,"window size")
    "stop time"                              MSUM(Measure1,"window size")           MAVG(Measure2,"window size")        MMAX(Measure1,"window size")
    Start time = 2008/01/01 00:00, Stop time = 2008/01/02 00:00, Step size = 4 hours, Window size = 6 hours
    on line 1 MSUM(Measure1,"window size') = SUM(measure1) for time between 2008/01/01 00:00 and 2008/01/01 06:00
    on line 2 MSUM(Measure1,"window size') = SUM(measure1) for time between 2008/01/01 04:00 and 2008/01/01 10:00
    on line 3 MSUM(Measure1,"window size') = SUM(measure1) for time between 2008/01/01 08:00 and 2008/01/01 14:00
    on line 4 MSUM(Measure1,"window size') = SUM(measure1) for time between 2008/01/01 12:00 and 2008/01/01 18:00
    on line 5 MSUM(Measure1,"window size') = SUM(measure1) for time between 2008/01/01 16:00 and 2008/01/01 22:00
    on line 6 MSUM(Measure1,"window size') = SUM(measure1) for time between 2008/01/01 20:00 and 2008/01/02 02:00
    on line 7 MSUM(Measure1,"window size') = SUM(measure1) for time between 2008/01/02 00:00 and 2008/01/02 06:00
    2008/01/01 00:00                 120        20         10
    2008/01/01 04:00                 110        10         12
    2008/01/01 08:00                 140        23         10
    2008/01/01 12:00                 130        24         13
    2008/01/01 16:00                 110        50         40
    2008/01/01 20:00                 120        26         15
    2008/01/02 00:00                 110        23         10It's example only - _numbers are random_
    *Can someone know how to design this report???*
    Edited by: Vlada on Sep 30, 2008 8:52 AM
    Edited by: Vlada on Oct 7, 2008 7:54 AM
    Edited by: Vlada on Oct 10, 2008 12:03 PM

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login. 
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode* and log in to the account with the problem. The instructions provided by Apple are as follows:
    Shut down your computer, wait 30 seconds, and then hold down the shift key while pressing the power button.
    When you see the gray Apple logo, release the shift key.
    If you are prompted to log in, type your password, and then hold down the shift key again as you click  Log in.
    *Note: If FileVault is enabled under OS X 10.7 or later, or if a firmware password is set, or if the boot volume is a software RAID, you can’t boot in safe mode. Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.  The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin. Test while in safe mode. Same problem? After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of the test.

  • When i highlight a group of cells the sum and average return a 0 yet there are numbers in the cells. Any ideas?

    I am using numbers to automatically calculate wages, when I highlight a group of cells containing the numbers 4 4 3 I would expect to get a sum value of 11 but i get nil? any ideas would be greatfully appreciated.

    Are the cells formatted as text rather than as numbers?

  • Accepting n numbers and Print their sum and average in Pl/SQL

    Hi All,
    I want to accept n number of values and i want to do some calculations on it.For this purpose I have tried "&" and "&&" operators. Is there any proper method for doing the same
    Thanks in advance
    Kiran

    hi
    I don't think that u can read from command line in frm a pl/sql block
    U may try using Java stored procedure/or other embeded language for that matter(example ..proc)
    ..................pushpi

  • Total and Average in RESULT of same keyfigure?

    Hi guyz,
    Just want to ask if having the SUM and AVERAGE result of one (1) keyfigure is possible in BEx Query Designer?
    Here is the report:
                                                                  Volume
    Customer A           Material X               100
                                     Material Y               200
                                     Material Z               300
                                     RESULT                600             --->  total --- (100 + 200 + 300) = 600
    Customer B           Material X              400
                                     Material Y              500
                                     Material Z              600
                                     RESULT               1500           ---> total --- (400 + 500 + 600) = 1500
    RESULT                                                1050           ---> average of result --- (600 + 1500) / 2 = 1050
    How will I do the AVERAGE? I already got the TOTAL since it's the DEFAULT in CALCULATION tab. But is it possible to also have the AVERAGE?
    Thank you!
    Loed

    Hi Loed,
    You can try to use Exeption aggregation to acheive this.
    OR
    You can use cell restrictions and get this done.There are many documents avaliable for Cell Restrictions
    Rgds
    SVU123

  • Is there a way to not include zero values in sums and an average?

    I'm working on a new performace evaluation & would like to sum the score of each line, then get an average of the total scores.
    example:  stength (1 value), Solid Performer (2 value), Performer (3 value), Recommend Development (4 value), N/A (zero value)  then a total score of all the values, not including the zero value. 
    Then an average score of all the scores given.
    Hope this makes sense! 
    Thanks in advance for the input!!!

    If you use the calculation option "The field is the ____ of the following fields:", nulll values and zero values are included as zero and the number of number of items use is the number of fields selected.
    If you want a different calculation, then you will have to write a custom script to sum and count the fields you want to include in the calculation.

  • Calculating Percent totals and Averages in SSRS

    Below is a report created using SSRS. I want to be able to calculate the percentage(%) total to add up to 100 % in the Total column. For some reason my averages are not working as you can see from the table. The idea is to calculate the averages of opportunities
    as well as Sold. But from my calculation, things are not adding up as I supposed. This report is not grouped by parent. How do I make this to work as it should? Thank you.
    (NB: Please zoom in to view the image)
    Zionlite

    Hi,
    According  to the description, I doubt you may manually add Total and Averages columns. Did you manually add Local and International or they were in a column group?
    You can use the following expression for the Opportunity Cost(averages) column in the total row:
    =Sum(Fields!opportunitycost.Value)/2
    How did you calculate the percentage column? If it is Sold value divided by Opportunity Cost value, use:
    =Sum(Fields!sold.Value)/Sum(Fields!opportunitycost.Value)
    Also try to define the scope in the expression and see if it make difference.
    If there is no progress, please capture the screenshot of your design tab.(Click on the report and capture the image of your report structure)
    Also, tell us the expression of the text box which in problem.
    Thanks.
    Tracy Cai
    TechNet Community Support

  • UCCE 7.5 how to get BHCA and Average Call Handle time?

    Hi everybody,
    I'm trying to do an audit of the existing UCCE system.
    Can someone please tell me how to get the BHCA and Average Call Handle time for agent?
    I did a SQL query against the CallTypeHalfHour table for all the entering Call Type but I'm not sure that's the right BHCA.
    Thanks in advance,
    Best Regards,

    Hi again Geoff,
    Before closing this thread, I'm curious about your query against TCD for average handle time.
    Here's mine using Skill_Group_Half_Hour
    SELECT
        SUM(HandledCallsTalkTimeToHalf) AS TalkTime,
        SUM(IncomingCallsOnHoldTimeToHalf) AS HoldTime,
        SUM(CallsHandledToHalf) AS HandledCalls,
          AHT =
                CASE
                WHEN SUM(CallsHandledToHalf) > 0 THEN (SUM(HandledCallsTalkTimeToHalf) +SUM(IncomingCallsOnHoldTimeToHalf)) / SUM(CallsHandledToHalf)
                ELSE 0
                END
    FROM t_Skill_Group_Half_Hour
    WHERE DateTime between '02/01/11 00:00' and '02/28/11 23:30'
    Besides, can you please also tell me how to get the Average Waiting Time (time before get answered by an agent) ?
    Thank you in advance, Geoff,
    Best Regards,

  • Subtotals - sum of average column

    Hi,
    I am new to PowerPivot so please excuse me if this is a stupid question.  I have a pivot table that uses a SQL view as its data source.  The pivot table looks like this:
    Price = average
    Qty = sum
    Value = sum
    Budget = average
    The way the view has been written the budget figure is given to grouping Customer + Product + MonthYear.  So, if I drop it into the pivot table as an average it comes up correctly.  The problem for me is that I want to turn on subtotals
    and get the sum of the average'd budget lines in the rowgroup above.  I have read that I can do this with PowerPivot by createing measures.  I guess my question really is "How do I use a measure in place of a subtotal in a pivot table
    report - how would I drag and drop it into place so it repeats as a subtotal would?"  The next question would be how would I write this measure?
    TIA

    Hi Julina,
    I had seen those threads before but didn't quite understand them.  I have got it now.  This is the formula that I have come up with, but I still get the averages of the averages, and not the sum of the averages:
    IF(COUNTROWS(VALUES(vwComprehensiveDeliveries_YRN[CustomerName]))>1,
    SUMX(
    SUMMARIZE(
    vwComprehensiveDeliveries_YRN,
    vwComprehensiveDeliveries_YRN[CustomerName],
    vwComprehensiveDeliveries_YRN[Product],
    vwComprehensiveDeliveries_YRN[BL_Year],
    vwComprehensiveDeliveries_YRN[BL_Qtr],
    vwComprehensiveDeliveries_YRN[BL_Month],
    "Customer Subtotal", AVERAGE(vwComprehensiveDeliveries_YRN[BudgetValue])
    [Customer Subtotal])
    AVERAGE(vwComprehensiveDeliveries_YRN[BudgetValue])
    I have tried it with only grouping SUMMARIZE by CustomerName, and combinations of the ones you see above. What have I done wrong?
    Thanks,
    C

  • Sum of Averages?

    Hello All,
    Am extremely frustrated at this point so i thought I'd post here and maybe someone can help me with a solution.  I have a report that I created that shows me the average amount of charges for a day.  How do I take a sum of the averages for for each day?  If i try to insert a summary and then use the average field it gives me an error.  Anyways around this?

    Since you are able to get the avg amt for each charge ID then create formula like this
    whileprintingrecords;
    numbervar i;
    i:=i+Average value calcualted;
    Place this in ChargeID group footer.
    Now create another formula like this
    whileprintingrecords;
    numbervar i;
    Place this in report footer which shows the sum of average.
    Hope this helps!
    Regards,
    Raghavendra

  • BPC Netweaver dimension formula SUM and AGGREGATE

    Hello
    Does anybody knows the arguments we can use with SUM and AGGREGATE in a dimension formula in BPC NW.
    I would like to aggregate data on a hirarchy but not from leaf level only the child at a specific level (do an average at a certain level and then do an aggragate of the children at upper level).
    Any idea how to use CHILDREN with SUM or AGGREGATE ?
    Thanks
    Regards

    Hi Anne,
    Note [1550366|https://service.sap.com/sap/support/notes/1550366] solves part of your problem (in SP06), but these formula results will not roll up the hierarchy and you still cannot reference formula members within formulas, so you will not easily be able to aggregate the averages that you calculate.
    It would probably be better to calculate your averages in script logic and assign them to normal base members.
    Ethan

Maybe you are looking for

  • Open in mail error

    hi there iphone 4 - iOS 6.0 I'm opening a pdf in adobe reader app, putting a sign and then trying to open the file in mail: it gives me system error and the app crash down thanks

  • Standby senario

    Hi, we are on 10g R2 Standard edition , then we can not have DATAGUARD. Then I imagine following Scenario. Will it function ?? Thanks for your opinions and your remarks and notices. Suppose I have a PRODDB (as primary DB) on Linux1 server. I duplicat

  • How to downlad a string to the Presentation server

    Hi all How we can download a string to the presentation server <b>without</b> converting it to  the internal table. Am having a XML data as string. I want to bring that to the presentation server without converting it to internal table. I have tried

  • How to setup MX Records etc at Host

    I am new to Leopard server. I have setup using advance a server for my small business (5 employees). to-date we have had a hosted solutions with both Website and Mail hosted by Melbourneit. I have now setup a leopard server and all services are worki

  • Os 8.2 installed befor 8.0, how can I get 8.0 prompt to appear so I can update

    MMy ipad 3 was replaced last week , old one wouldn't download 8.0, now with my replacement ipad a software update appeared stating 8.2 was downloaded and ready to install, so I did, how do I download and install 8.0 ? It keeps indicating my software