Me again! - printing count results

hello,
i made a post earlier about this and someone replied but i still couldn't get it to work. i have to create a game (paper scissors rock) and it has to keep count of the number of wins player 1 and 2 have. i have to use separate methods. the problem is for some reason when it prints the number of wins it comes up with 0. i have cut out any unneeded code. please please help:
public class question2a
public static void main(String[] args)
char quit = 'y';
char c1 = 0;
char c2 = 0;
int player1wins = 0;
int player2wins = 0;
do
question2a.getinput();
question2a.winnercalculation(c1, c2, player1wins, player2wins);
System.out.println("Do you want to play again [y/n]");
quit = SavitchIn.readChar();
SavitchIn.read();
} while (quit != 'n');
question2a.outputresults(player1wins, player2wins);
public static void getinput()
char c1;
char c2;
int player1wins = 0;
int player2wins = 0;
System.out.println("Player 1 please enter a letter");
c1 = SavitchIn.readChar();
SavitchIn.read();
System.out.println("Player 2 please enter a letter");
c2 = SavitchIn.readChar();
SavitchIn.read();
private static void winnercalculation(char c1, char c2, int player1wins, int player2wins)
char rock = 'r';
char paper = 'p';
char scissors = 's';
if ((c1 == rock) && (c2 == scissors)) //rock and scissors
System.out.println("Player 1 Wins!");
player1wins = player1wins + 1;
else if ((c1 == rock) && (c2 == paper)) //rock and paper
System.out.println("Player 2 Wins!");
player2wins = player2wins + 1;
else if ((c1 == scissors) && (c2 == rock)) //scissors and rock
System.out.println("Player 2 Wins!");
player2wins = player2wins + 1;
public static void outputresults (int player1wins, int player2wins)
System.out.println("Player 1 has had "+player1wins+" number of wins");
System.out.println("Player 2 has had "+player2wins+" number of wins");
if you need the code for the savitchIn tell me and i will post it

Local variables are defined inside of methods. Fields are defined outside of methods. (Well there's more to it than that but that's how you can tell them apart.)
But actually I misread your code. You defined c1 and c2 as local variables in main().
So your code is fundamentally flawed.
The easiest thing is to make these fields, static as mambo2 said:
public class question2a
  static char c1 = 0;
  static char c2 = 0;
  static int player1wins = 0;
  static int player2wins = 0;
  public static void main(String[] args)
// etcOr, better yet, you could rework your code to actually be a real OOP program.
Either way, read the manual and learn about field/variable scoping, static vs instance fields, etc.

Similar Messages

  • I am trying to print a color photo on my MacBook Pro from iPhoto (not using Photoshop) using Epson 2200 printer, and everything I do in the Color Matching and Print Settings results in a photo with a pink cast to it. What am I doing wrong?

    I am trying to print a color photo on my MacBook Pro from iPhoto (not using Photoshop) using Epson 2200 printer, and everything I do in the Color Matching and Print Settings results in a photo with a pink cast to it. What am I doing wrong?

    Have you checked the ink cartridges and made sure the nozzles are clear? Are you able to print from outside of iPhoto with the correct color?
    Try the following: make temporary copy of the library and do the following:
    1 - delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your
         User/Home()/Library/ Preferences folder.
    2 - delete iPhoto's cache file, Cache.db, that is located in your
         User/Home()/Library/Caches/com.apple.iPhoto folder. 
    3 - launch iPhoto and try again.
    NOTE: If you're moved your library from its default location in your Home/Pictures folder you will have to point iPhoto to its new location when you next open iPhoto by holding down the Option key when launching iPhoto.  You'll also have to reset the iPhoto's various preferences.
    OT

  • How do you change the FILE "print code" resulting printed font size?

    I would like to adjust the "Print Code" resulting printed document font size. Though the changes can be made in display font for the Code window via a file or the Preferences Menu, I cannot find the style information to change the Print Code.
    Thanks

    Thanks again for your reply.
    I would like the code print out font to be a smaller size. Currently, it ls printing at 12 pt Monaco ( I can emulate this exactly by printing the same document in an editor set as Monaco 12pt ).  However, the settings (see below) are set at Monanco 9pt. This works on the screen, but not for printing.
    http://goo.gl/eXhnz   > screenshot of Setting show "smallest".
    Yet the code:print gives me more characters per line, resulting in  many more pages per printout. The "print preview" shown in my last message is exactly what the printed page looks like as well.
    NOTE: with the same settings ("smallest Monaco 9pt), Dreamweaver CS3 on OSX *does* code:print the smaller size, though without color coding. Dreamweaver CS 5 on my system does not.
    Thank you.
    Jay

  • How to print count page of HP LaserJet Pro M1214nfh Multifunction Printer

    Hi there, I need to find out how to print counter of my printer, I mean the total number of printed pages.
    my printer model is :
    HP LaserJet Pro M1214nfh Multifunction Printer
    thanks alot.

    Hello motevalli69,
    Welcome to the HP Forums.
    To get the number amount of the pages printed, I am going to give you the User Guide for your printer.  Please go to the section Table 2-5.  Reports Menu. 
    I hope this is the information you are looking for.
    Please feel free to write me back if you have any other questions.
    Cheers,  
    Click the “Kudos Thumbs Up" at the bottom of this post to say “Thanks” for helping!
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    W a t e r b o y 71
    I work on behalf of HP

  • Problem when Counting results of a query

    Hi all
    In our application, we use the Toplink Essentials Queryframework API to create queries because of JPA limitations.
    Now I have a problem: I want to count the results of a existing query, i.e. I have a ReportQuery and I want to count the results of it.
    I tried the following:
    ReportQuery query = ...
    ReportQuery countQuery = new ReportQuery(Pivot.class, builder);
    countQuery.addCount(COUNT,
    ExpressionBuilder.from("id", builder.subQuery(query)));
    countQuery.setShouldReturnSingleValue(true);
    return Integer.valueOf(session.executeQuery(countQuery).toString());
    Now it seems that Toplink executes the query but the result is not correct, i.e. the count result is NOT the same as the number of results in the original query.
    The subquery may contain group by's, a where clause and so on...
    Anyone has an idea how to count the number of results of another query in Toplink?
    It should have the same affect as a simple sql "select count(*) from (select ...)" query.
    Regards
    Michael

    Not exactly sure what your doing, what does the original ReportQuery select?
    You probably want to do something like the following:
    originalQuery...
    ReportQuery countQuery = new ReportQuery(Pivot.class, countBuilder);
    countQuery.addCount("id");
    countQuery.setSelectionCriteria(originalQuery.getSelectionCriteria());
    You may need to also call rebuildOn() if you reuse the same selection criteria from a different query.
    i.e.
    countQuery.setSelectionCriteria(originalQuery.getSelectionCriteria().rebuildOn(countBuilder));
    James : http://www.eclipselink.org

  • BEx Map in Excel: Print only result area

    Hi experts,
    I am in BEx Map - Excel, and I am trying to print the result area ONLY, without key figures, legend and so on...
    Print Preview in Excel shows the key figures on the left, the legends on the right and a little version of the map (as if way too zoomed out) in the middle.
    I know there is a post dedicated to the "print only result area" but its solution is "web only"
    Thx,
    Olivier

    Arun,
    Attaching a map in BEx-Excel is different from attaching a chart. When attaching a map, you can't choose in which sheet/workbook the map will be displayed. A new sheet is automatically added to the workbook holding the BEx query, period.
    But thx anyway. I did try your thought

  • How to sum the count results?

    Hi,
    I have this query:
    SELECT SUM (cnt) FROM
    select max(timestamp), min(timestamp), count(1) as cnt from table1
    union
    select max(timestamp2), min(timestamp2), count(1) from table2
    It display sum of all count results. But how to display each result from query and sum result at the end?
    Best.

    OK, thanks, that helps a lot. Though if you could put {noformat}{noformat} before and after your code snippets that would help further.
    So you basically want a total at the end:WITH test_data AS (
    SELECT 1 col1, TO_DATE('16-AUG-08', 'DD-MON-YY') max_ts, TO_DATE('16-AUG-08', 'DD-MON-YY') min_ts, 1000 cnt FROM DUAL UNION ALL
    SELECT 1, TO_DATE('31-OCT-08', 'DD-MON-YY'), TO_DATE('31-OCT-08', 'DD-MON-YY'), 1000 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('10-FEB-09', 'DD-MON-YY'), TO_DATE('01-JAN-01', 'DD-MON-YY'),422 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('20-FEB-09', 'DD-MON-YY'), TO_DATE('20-FEB-09', 'DD-MON-YY'),1000 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('20-FEB-09', 'DD-MON-YY'), TO_DATE('20-FEB-09', 'DD-MON-YY'),14825 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('27-FEB-09', 'DD-MON-YY'), TO_DATE('27-FEB-09', 'DD-MON-YY'),1000 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('28-FEB-09', 'DD-MON-YY'), TO_DATE('26-FEB-09', 'DD-MON-YY'),1000 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('01-MAR-09', 'DD-MON-YY'), TO_DATE('01-MAR-09', 'DD-MON-YY'),1000 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('05-MAR-09', 'DD-MON-YY'), TO_DATE('16-AUG-08', 'DD-MON-YY'), 5150 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('27-APR-09', 'DD-MON-YY'), TO_DATE('30-OCT-08', 'DD-MON-YY'),8733 FROM DUAL UNION ALL
    SELECT 1, TO_DATE('27-APR-09', 'DD-MON-YY'), TO_DATE('20-FEB-09', 'DD-MON-YY'),10000 FROM DUAL)
    -- end test data
    SELECT col1, max_ts, min_ts, sum(cnt) total_cnt
    FROM test_data
    GROUP BY ROLLUP((col1, max_ts, min_ts));
    1 16-AUG-08 16-AUG-08 1000
    1 31-OCT-08 31-OCT-08 1000
    1 10-FEB-09 01-JAN-01 422
    1 20-FEB-09 20-FEB-09 15825
    1 27-FEB-09 27-FEB-09 1000
    1 28-FEB-09 26-FEB-09 1000
    1 01-MAR-09 01-MAR-09 1000
    1 05-MAR-09 16-AUG-08 5150
    1 27-APR-09 30-OCT-08 8733
    1 27-APR-09 20-FEB-09 10000
    45130
    11 rows selected.

  • I keep getting this message and PSCC will not open:Unable to start your subscription for Adobe Photoshop CC.  I keep trying again with no results.  I am on automatic pay system.  This should not happen.

    I keep getting this message and PSCC will not open:Unable to start your subscription for Adobe Photoshop CC.  I keep trying again with no results.  I am on automatic pay system.  This should not happen.
    I had it open a few minutes ago.  Closed it and went to reopen to no avail. How can I open and continue to work?

    Does your Cloud subscription properly show on your account page?
    If you have more than one email, are you sure you are using the correct Adobe ID?
    https://www.adobe.com/account.html for subscriptions on your Adobe page
    If yes
    Some general information for a Cloud subscription
    Cloud programs do not use serial numbers... you log in to your paid Cloud account to download & install & activate... you MAY need to log out of the Cloud and restart your computer and log back in to the Cloud for things to work
    Log out of your Cloud account... Restart your computer... Log in to your paid Cloud account
    -Sign in help http://helpx.adobe.com/x-productkb/policy-pricing/account-password-sign-faq.html
    -http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html
    -http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html
    -http://helpx.adobe.com/creative-suite/kb/trial--1-launch.html
    -ID help https://helpx.adobe.com/contact.html?step=ZNA_id-signing_stillNeedHelp
    If no
    This is an open forum, not Adobe support... you need Adobe staff to help
    Adobe contact information - http://helpx.adobe.com/contact.html
    -Select your product and what you need help with
    -Click on the blue box "Still need help? Contact us"

  • WM: Enter Cycle Count Results (LI11N)- Time Stamp

    When cycle count results are entered, only the date of the count is recorded in table LINV. We are interested in capturing the time of entry as well for productivity related reporting.
    Is anybody aware of a solution that can accomplish this. For example populating a Z Table via user exit/BADI etc...

    Hello,
    You can do cycle counting with Rf transaction LM59 for the serialised material.
    1.My experience says when you have HUM activated then to track material HU & serialisation profile works together.
    2.You can do cycle counting of serailised & non serialsed material through Rf gun but clearance of this material will be issue. You may have to create one more transaction to clear the difference of  serialised materials like LI20
    Hope this input helps.
    Regards,
    Prashant

  • Count result

    Hello,
    I'm having trouble to understand how to display the count result from a row
    I want to list my categories with number of post:
    Music (3)
    Guitar (12)
    Drum (4)
    I have 2 table:
    Categories with 2 field -category_id and category_name
    Table post with several field like user id, name, title, etc
    I have a cat_id in this table who make reference to category_id
    set to InnoDB
    How to do this with Dreamweaver?

    >I'm having trouble to understand how to display the count result from a row
    A count result from a row?  Each row has a count of one, right? You might want to rephrase your question.
    >How to do this with Dreamweaver?
    This is not really a DW question, it's a SQL question:
    SELECT category_name, count(*) from
    post, categories
    where post.cat_id = category.category_id
    group by category.category_name

  • Print test results

    Hi
    I am doing quality testing. I want to print test results. What is the menu path or T Code for the same.
    Regards
    Nandini

    Dear Nandini
    You can use QGP1 tcode for the same
    Regards
    Gajesh

  • How to Input quickly year-end Stock Count Results

    Gurujee,
    Our company has 3 sites for inventory which is holdin  about 2,000 SKUs (Stock Keeping Units) value with 100 M Dollars. 
    Please educate me how to quickly input stock count results in matter of say 12 hrs - i.e. between december 31, 2009 and start new year January 1, 2010.
    How to do up and down adjustments QUICKLY within same categories, e.g. in Drinks up and down adjustments for items with similar values, but different flavors ?
    Rgds,
    Seifudin

    Ah, but I am unsure as to which part of my code goes where "..." is.
    Is it basically everything that I have put in the for loop?
    Right, I tried the following code:
    import java.util.Scanner;
    /* This program displays pass results for students */
    class StudentMarks
         public static void main (String[]args)
              Scanner input = new Scanner(System.in);
              int x, noOfStudents, mark;
              System.out.println ("Input number of students");     //outputs text
              noOfStudents = input.nextInt();
              while ((mark = input.nextInt()) != -1)
                  for (x = 1; x <=noOfStudents; x++) //loops no. of times of no. students
                             System.out.println ("Input exam mark for student");
                             mark = input.nextInt();
                             if (mark >= 40)
                                  System.out.println ("Pass");
                             else
                                  System.out.println ("Fail");
    }I don't know if this is the right way of going about it, but I am having a problem with it. When it asks me to input the number of students, I enter a number, but I have to enter it a second time for it to go to the next section, which is to ask for the mark. It then repeated the question of how many marks until I entered -1 to stop the program. So the number of students input is disregarded.
    So I can only assume I've put the wrong part of the code where "..." was? I really don't know where to go with this so if someone could just put on the right lines here, that would be great, thanks!

  • Printing Search results

    Hello,
    is it possible to print only those pages brought up by a search with a single print command?
    e. g.: A 300 pages document, the search for "Paris" brings up 80 hits on 75 pages.
    Can I print those 75 pages with a single command or do I have to jump from page to page and print the actual page of every result?
    Thanks for help –
    Johann

    With Adobe Reader? - No.
    Starting with Acrobat X, yes.
    http://www.pdfforlawyers.com/2010/10/how-to-save-or-print-search-results-in-acrobat-x.html
    Be well...

  • Photoshop CS5 Print Printing problem: print count and print to ICC profile

    Since Adobe still haven't acknowledge the printing issue with CS5, I start this thread to report my own problems.
    Problem 1:
    print copy count is not working. The first print is always one print regardless how many copies you set in the dialog window. The next print will actually print the copies set in the previous print job.
    This is a well documented problem, and until today no fix.  I am not too worried about this problem because I can always print one copy each time to get job done, until the day Adobe acknowledge and fix the problem.
    Problem 2:
    when I let the Photoshop manage color and print to a custome ICC profile (generated by Spyer3Print), Photoshop RANDOMLY decides to print a light colored magenta cast picture.  It's like Photoshop has used the wrong ICC.  Now every time I print a 13x19, I have to pray.  Because this thing is so random, I can't even reproduce the problem consistantly.
    here's the information about my system:
    Windows 7 Ultimate 64Bit (not a fresh system) with 8GB RAM.  Printer drivers installed: Canon Pro9000II, Canon MP600, Epson 1400.
    I experience problem 2 after I installed CS5 with Epson 1400 printer, but not too frequent.  Later on I installed drivers for Epson R1800, Epson R2400, and I mainly print with R2400.    All the printer drivers, software updates are the lastest available.
    I was a software developer. I wrote windows application before. I am pretty sure the problem is with CS5 based on my knowledge.  If I wrote an Windows application that crashs Windows or another party's appliction, I certainly would not blame Microsoft or another party for not writing a bulletproof system. I would try to find a workaround in my own application.  That's just my take. Adobe may have different mind set. They are still pointing finger to MS and Epson.

    I don't condone the problems, but a workaround I've recently read about for the copy count problem is to do the following, in order:
    1.  Set the copy count you want.
    2.  Click the Print Settings... button to enter the printer driver setup dialog.
    3.  [OK] out.
    4.  Print
    This is reported to get the proper copy count into the print driver and make it "stick".  I just tried it and it seems to work.
    Keep in mind you may want to go through this again after printing to get the copy count to default back to 1 for the next print.
    -Noel

  • Printing count of records before and after a command in a PL/SQL

    Hi: I have the following PL/SQL script
    declare
    l_sysdate date := sysdate;
    begin
    INSERT INTO a_mnsnotes SELECT * from mnsnotes where TKT_NBR in (
    select TKT_NBR from mnsinterface where MNS_STATUS=5 and CLOSED_DATE < (((l_sysdate-30) - to_date('01-JAN-1970','DD-MON-YYYY')) * 86400));
    delete from mnsnotes Where
    TKT_NBR in (select TKT_NBR from mnsinterface where MNS_STATUS=5 and CLOSED_DATE < (((l_sysdate-30) - to_date('01-JAN-1970','DD-MON-YYYY')) * 86400));
    commit;
    end;
    /I want to assign the number of records in the two table (a_mnsnotes and mnsnotes) to two variables so I can print in one line the numberof records for both tables before and after the procedure. How do I set the output of a sql command (select count(*) from mnsnotes) to a variable within the pl/sql?
    Thanks
    Ravi

    Also I'm guessing this:
    (((l_sysdate-30) - to_date('01-JAN-1970','DD-MON-YYYY')) * 86400);
    is because closed_date is stored as number of seconds since 01-JAN-1970, which should be turned into a date ASAP. Never store dates as anything other than DATE datatype (or maybe TIMESTAMP in more recent versions).
    It's not right, as sysdate will have a time component so if this code is run at 8am it will give different results to if it is run at 9pm. And not all months have 30 days.
    Have you considered TRUNC(add_months(sysdate,-1)) instead of l_sysdate-30 ?

Maybe you are looking for

  • Where is the web root directory in Database 10g Express Edition and APEX

    I'm developing a mod_plsql application with database express edition and the APEX version that comes with. It works fine for developing mod_plsql applications(http://localhost:8080/apex/mypackages), but I could not find the different web directories

  • Serial number InDesign 5.5

    Hello, I know there are more questions about finding the serial code for InDesign, but nothing works for me. I could find the serial code for Photoshop, Illustrator without a problem. But it's different with InDesign. I haven't registered the program

  • Multi query PDF report in apex 4.0

    Hi All... I have created a report in apex 4.0. it consists of more than 40 queries. Initially it was working fine but now it has a very unpredictable behavior. Some of the queries were not retrieving the data. I just deleted them and then recreate th

  • Adobe Acrobat 8 Standard won't register

    Having a problem registering acrobat after reinstalling after a system crash meant that I had to wipe the hard drive and start again. I get an error message saying "a problem was encountered while trying to send information over the internet". It ins

  • Convert multi-page pdf to multi-page jpg files?

    Hi, My boss has asked me to convert a large number of multiple-page pdfs into multiple-page jpgs. I have been able to convert the pdfs to jpgs in photo shop using image processor, but the processor only captures the first page of the multiple page do