I have solved some questions, please check if my answers are correct

Hi every Java aces,
I have solved some programming questions, please check if my answers are correct. Thanks
Here are the questions and the answers to each question
(a) Write a method called add that takes three integers as parameters and returns an
integer that is the sum of the three parameters.
(b) Write a method called max that takes three integers as parameters and returns the
largest of the three integers.
(c) Write a method called printMax that takes three integers as parameters and prints
the maximum value to the screen. The method should return nothing. The method
should print the words \The maximum value is " followed by the maximum value,
followed by a new-line character. You should try to use the max method that you
wrote earlier.
(d) Write a method called min that takes three integers as parameters and returns the
smallest of the three integers.
(f) Write a method called ticketPrice that takes one integer parameter representing
the age of a person, and returns the price of a movie ticket in dollars (as a
oating
point value). Children under 6 get in for free (0.00), people that are 18 or under
pay 8.50, senior citizens (65 or older) pay 6.50, and all other people pay 10.00.
(g) Write a method called isDivisor that takes two integers as parameters and returns
true if the rst parameter is a divisor of the second parameter or false otherwise.
We say that m is a divisor of n, or that m divides n, if there is an integer k such
that n = k m. Note that 1 divides every integer, and every integer divides i
itself .
here are my codes
public class Methods
// This is method (a)
public static int add (int a, int b, int c)
int sum = a + b + c;
return sum;
// This is method (b)
public static int max (int a, int b, int c)
int largest;
if (a > b)
if (a > c)
{ largest = a; }
else
{ largest = c;}
else
if (b < c)
{ largest = c; }
else
{ largest = b;}
return largest;
// This is method (c)
public static void printMax (int d, int e, int f)
int maxValue;
maxValue = max (d, e, f);
System.out.println ("The maximum value is " + maxValue);
// This is method (d)
public static int min (int a, int b, int c)
int smallest;
if ( a < b )
if ( a < c )
{ smallest = a; }
else
{ smallest = c; }
else
if ( b > c )
{ smallest = c; }
else
{ smallest = b; }
return smallest;
// This is method (f)
public static double ticketPrice (int age)
double price;
if ( age < 6 )
{ price = 0.00; }
else
if ( age <= 18 )
{ price = 8.50; }
else
if ( age < 65 )
{ price = 10.00; }
else
{ price = 6.50; }
return price;
// This is method (g)
public static boolean isDivisor ( int m, int n )
boolean result;
int check1;
double check2;
check1 = n / m;
check2 = (double)n / m;
if ( check2 == check1 )
{ result = true; }
else
{ result = false; }
return result;
}

Here are my codes
// This is method (a)
  public static int add (int a, int b, int c)
    int sum = a + b + c;
    return sum;
  // This is method (b)
  public static int max (int a, int b, int c)
    int largest;
    if (a > b)
      if (a > c)
      { largest = a; }
      else
      { largest = c;}
    else
      if (b < c)
      { largest = c; }
      else
      { largest = b;}
    return largest;   
  // This is method (c) ?
  public static void printMax (int d, int e, int f)
    int maxValue;
    maxValue = max (d, e, f);
    System.out.println ("The maximum value is " + maxValue);
  // This is method (d)
  public static int min (int a, int b, int c)
    int smallest;
    if ( a < b )
       if ( a < c )
       { smallest = a; }
       else
       { smallest = c; }
    else
      if ( b > c )
      { smallest = c; }
      else
      { smallest = b; }
    return smallest;
// This is method (f)
  public static double ticketPrice (int age)
    double price;
    if ( age < 6 )
    { price = 0.00; }
    else
      if ( age <= 18 )
      { price = 8.50; }
      else
        if ( age < 65 )
        { price = 10.00; }
        else
        { price = 6.50; }
    return price;
  // This is method (g)
  public static boolean isDivisor ( int m, int n )
    boolean result;
    int check1;
    double check2;
    check1 = n / m;
    check2 = (double)n / m;
    if ( check2 == check1 )
    { result = true; }
    else
    { result = false; }
    return result;
   // This is method (h)
  public static boolean isProduct ( double a, double b, double c )
    boolean result;
    if ( a == b*c )
    { result = true;}
    else
    { result = false;}
    return result;
     

Similar Messages

  • Adobe FLME Error Message "Please check if video devices are connected properly and are not used by any other application."

    Hello, I'm trying to use my MAC Book Pro with Adobe FMLE. Once I select either my internal or external camera and microphone, in the live encoder I get this error message. "Please check if video devices are connected properly and are not used by any other application." The Facetime HD camera works in Photo Booth. Can someone assist me in what to do please, Thanks in advance!

    Hi all ,
    We found the solution for this issue .
    We have installed the crypto library in global executable directory and any way it will replicate those binaries to individual application servers.
    But the parameters are still looking for global executable directory for loading crypto library during time.
    So all application servers are trying to load crypto library files from global "exe" instead of local directory, which was clustered .Sometimes during  heavy network load it may cause some delays to load the libraries to individual application servers and in turn is causing the license key issues.
    Note 982056 - The license key library has not been initialized yet..
    SAP Recommend option for all SSF parameters should be instance profile parameters not in default parameters..This was mentioned in below note:
    Note 662340 - SSF Encryption Using the SAPCryptolib --- .
    But in our Environment SSF and SEC parameter were set in DEFAULT profile instead Instance profile.
    Recommendations:
    o     ssf/ssfapi_lib  = <Path and file name of SAPCRYPTOLIB>
    o     sec/libsapsecu  = <Path and file name of SAPCRYPTOLIB>
    This was mentioned in the below SAP HELP.
    http://help.sap.com/saphelp_nw04/helpdata/en/3d/bf463c6796e61ce10000000a114084/frameset.htm.

  • NSS4100 RAID DOES NOT START Please check that all components are present

    Hi, The NSS4100 storage system failed to start the raid10.
    The message is:
    Failed to start RAID
    Please check that all components are present
    All the disks are present as you can see in the attached image.The system has been restarted twice. Is there a possibility to start again the raid without losing data?
    Thank you,Dan

    Hi.
    I have exactly the same problem which is discribed first in this Thread.
    We have a NSS 4000.
    4 HDs - RAID 5
    SATA 2 was faulty an the RAID was degraded
    There was no problem with the data on the Volumes. I pulled the disk on SATA 2 (which was the one which no longer was in the RAID). Ich pushed it in again. Then on RAID site i clicked on 'Edit' and then on 'Add'. I thought the RAID would then synchronize the fourth HD and the status is going to be 'Running' and we are safe of one harddisk failiure.
    Log:
    2010-01-04 13:04:49 RAIDA : Rebuild Finished
    2010-01-04 13:04:46 RAIDA has failed.
    2010-01-04 13:04:46 RAIDA has suffered a drive failure.
    2010-01-04 11:27:15 RAIDA : Rebuild Started
    While the process was synchronizing i could access the data on the Volumes.
    But after 90 min the RAID was broken. No Access on the data - no shares. The Status is 'Stopped'. All 4 HDs are Online and the Health Status is 'Passed'
    If i click on Start:  "Failed to start raid. Please check that all components are present."
    I have no saved configuration because i thought that there will be no problem with this 'basic procedure' of a RAID device.
    Even if the HD is broken the RAID should be doing his job in 'Degraded' mode. Thats because i am using a RAID.
    So am i right that our data is gone because only one HD from a RAID 5 seems to be broken?

  • I have several charges on my checking account statement that are not mind.

    I have several charges on my checking account statement that are not mine.

    You've checked the purchase history on your iTunes account ? If you log into your account on your computer's iTunes via the Store > View Account menu option, you should then see a Purchase History section with a 'see all' link to the right of it, click on that and you should then see a list of your purchases. On your iPad you can see the last 90 days purchases via http://reportaproblem.apple.com
    If you don't recognise the charges, and nobody else has access to your account or devices and made them, then try contacting iTunes Support : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • My Apple ID asks for answers to security questions which I never input. I have searched how to reset my security questions and have found that the option below where your answers are to be input to reset questions does not exist on my iPhone 5c

    My Apple ID asks for answers to security questions which I never input. I have searched how to reset my security questions and have found that the option below where your answers are to be input to reset questions does not exist on my iPhone 5c

    You need to ask Apple to reset your security questions. To do this, click here and pick a method; if that page doesn't list one for your country or you're unable to call, fill out and submit this form.
    They wouldn't be security questions if they could be bypassed without Apple verifying your identity.
    (114119)

  • HT5312 I want to purchase an APP on my ipad. When I enter the answers to the security question, it comes back invalid. The answers are correct. I need help re-setting my answers.

    I want to purchase an APP on my ipad. When I enter the answers to the security question, it comes back invalid. The answers are correct. I need help re-setting my answers.

     Account Security Team (AST) 
    Check the AppleCare number for your country here:
    http://support.apple.com/kb/HE57
    Call them up, and let them know you would like to be transferred to the Account Security Team.

  • I have an iphone 4 with a talkmobile contract sim. I am unable te send or receive mms. I have spoken to talkmobile customer service, my phone settings are correct. Aplle say that it is a network problem, can anyone help?

    I have n iphone 4 with a talkmobile contract sim. I cannot send or receive msm. I have spoken to talkmobile customer service, my phone settings are correct,Aple say it 8is a network problem!! Help!!

    talkmobile is not a supported carrier. It's very likely that you have the same problem suffered by people who attempt to use T-Mobile in the U.S. MMS simply will NOT work because the network is not compatible with the iPhone. If you want full functionality, you will have to switch to a supported carrier.
    A list can be found here: http://support.apple.com/kb/ht1937

  • Checking AppleID, my addresses are correct, but on second step for security, Apple advises it will send text for assistance and lists an account I do not know.  How do I change this?

    Checking AppleID, my addresses are correct, but then on second step for security, apple sent text to unknown address.  How do I change this?

    Does this apply?
    If you're asked for the password to your previous Apple ID when signing out of iCloud - Apple Support

  • Some Question Please answer I am a beginner

    Hello Friends
    I have some question
    1. what is the difference between forms and report
    2. what is the difference between simple report and xml publisher report
    3. what are the types of Database Types in Oracle
    4. what are the types of SQL Loader
    In Advance Thanks

    1) Oracle form: acts like an user interface between data base and user input. User can Query the data and view the under lying data.Basically Oracle forms are front end tools for user interaction and application setup.
    Oracle Report: is the reporting component in EBS, where in when the user gets the data based on the parameters provided.
    refer to the developer Guides for more information.
    http://www.oracle.com/technetwork/developer-tools/forms/index.html
    2) template will be used in the XML publisher which can be developed by a RTF file, and registration of the report in EBS has a separate process. Check the below link for more information
    http://docs.oracle.com/cd/B34956_01/current/acrobat/120xdoig.pdf
    3) Oracle data types are similar like other languages, these are used for handling the data.There are several built-in data types, check the below link.
    http://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm
    4) SQL loader is basically used to load the data from flat file to data base table by using a control file. Please go through the below link for more information and concepts.
    http://docs.oracle.com/cd/B19306_01/server.102/b14215/ldr_concepts.htm
    Regards,
    -

  • [SOLVED] Some questions about a recently submited package (cgames)

    Hi there, when searching for ncurses sokoban-like games I ended up finding a great one that wasn't at the AUR yet. I submitted it (the package is named cgames) but I have some questions.
    1- The source code provided by the developer has 3 games. Should I have packaged each one individually? I decided this way because they are so small that I figure nobody would have a problem in having them all even when just wanting to play one of them (you can always change the make command in the PKGBUILD if you want a single game).
    2 - The original package had some compiling problems due to a function called getline (already existing in stdio.h) and I solved this problem with a sed command. Is this the proper way to do it? Should I have created some patch file or something?
    3- I'm 99% sure the game works in 64bit archs, but 99 isn't 100. Can anyone try it out for me, so that I change the PKGBUILD? I know I should have tested it but I don't have the time to install a 64b arch in the next few days.
    Thank you in advance
    Last edited by jlcordeiro (2010-03-29 15:33:58)

    Yeap, a bit
    Anyway, all done (i think)
    Second release:
    - Replaced sed command with a patch
    - Added x64 arch
    - Fixed a little bug with the configure command
    Last edited by jlcordeiro (2010-03-29 15:32:42)

  • [Solved] Some question's about mutt.

    Hello!
    I searched for a nice e-mail client and  I found mutt it's really nice but here's some question's...
    1.What about images in post's and how would they will be open?
    2.Does muttt support Unicode (UTF-8)?
    Thtat's all for now!
    BTW.If somone has better proposition for a mail client please post (except KMail and Thunderbird).
    Last edited by SpeedVin (2010-07-30 11:01:12)

    1) mutt uses .mailcap to specify what applications to use to open up attachments (all images in emails are attachments).
    2) Yes. You may want to search the mutt mail archives for specifics (I know it's come up on there quite a bit). mutt will use the charset specified in the email itself, and you can set the "assumed_charset" variable to handle emails that don't specify it.
    More here:
    http://www.mutt.org/doc/devel/manual.html
    http://marc.info/?l=mutt-users   <- mailing list archives
    http://wiki.mutt.org/
    http://www.mutt.org/#doc
    EDIT Jason beat me to it - and I forgot the FAQ.
    Also, if you like minimalist, try nmh (don't know if it's in AUR).
    Oh and many people like Claws email (and/or Sylpheed Claws). I thnk that's the nicest of the GUI clients that I've looked at.
    Last edited by skanky (2010-07-30 09:59:44)

  • I have bought some albums in the past but they are all not in purchased section no more

    hi all,
    I have bought some albums in the past from itunes store but now it is stating i only have about 27 songs instead of about 250.
    Can someone please tell me why this is and where the rest of the albums will be.
    Thank you for your time.

    Of course not.  The caller wanting to take up a half hour of the already overwhelmed employee should be told they will be in line like everyone else and leave a callback number so the employee can call them back when his turn comes up. 

  • Checking three 'if' statements are correct or wrong

    Hi Guys
    I'm working on a quiz where a user has to drag three movie clips to correct positions then press the 'next' button to move on (calls funtion nxt)
    I have nxt function to check to see if the three movie clips have been dragged onto the three correct positions (other movieclips), the code works but only if all three are correct.
    I want the function to check to see if all the clips have hit the right target,
    if so, then add +1 to the 'score' and go to frame 'end'
    if the clips aren't on the right target then just go to frame 'end'
    At the moment the nxt function doesn't work if the answers are wrong.
    Can anyone point me in the right direction?
    The quiz is here online, only four questions
    and here's the code for question 4 that i need some help with...
    function nxt(event:MouseEvent):void
    if (asc1_mc.hitTestObject(blank1_mc))
    if (shou_mc.hitTestObject(blank2_mc))
    if (crossb_mc.hitTestObject(blank3_mc))
    {score++;
    gotoAndStop ("end")}
    else
    {gotoAndStop ("end")}

    How about this?
    function nxt(event:MouseEvent):void
         if ((asc1_mc.hitTestObject(blank1_mc)) &&
              (shou_mc.hitTestObject(blank2_mc)) &&
              (crossb_mc.hitTestObject(blank3_mc))
             score++;
         gotoAndStop ("end");

  • I want to restore my ipod 4g to ios 6.1.2 but it said error code 3194 i updated itunes and i checked my host file and it won't work Thank you for choosing the Apple Store. If you have any additional questions, please chat us again. You are currently not i

    i want to restore my ipod 4g to ios 6.1.2 but it said error code 3194 i updated itunes and i checked my host file and it won't work and i am running 6.1.5 at the moment

    That's because downgrading is not supported.

  • Slower than slow. Not the first I know but have some questions please.

    Hello fellow Verizon users. First let me tell you about my pc.  It's second hand,  HP Pavilion, Windows Vista, 32-bit, Windows 7, sp2. Hope this helps. My router is Gateway Westell 7500.
    I have been reading the replies to others who have posted that their connections are very slow, but do not understand the replies and don't have the technical know-how to report back all of the info. 
    There was one link that I did click on where I typed in the IP address and it brought up my router information. All but two headings read that , more or less if you don't know what you are doing..Don't!  However I did write one thing down. One was the down speed which is 3360 Kbps, and the up speed is 864 Kbps. Does this say anything about why my internet is so slow? 
    In task manager I noticed that there is information .... Processes, performance, CPU Usage and so forth. Although these numbers mean nothing to me, do these stats say anything about why I am having this issue? I was told at one time that the Services tab that shows a listing of the names and status of functions that are running, needs to be cleaned up. Here again, I do not know what these functions are and what they are for.
    When I first signed on with Verizon High Speed Internet, everything ran fine and fast.  I have talked to tech support about this and they took control over my pc, but did not fix anything.
    Off of the topic, but when I would try to get help on Verizon Help Page, all I'd get is IE Cannot Display This Webpage. Called tech support and they installed Google Chrome.  So what did that do?  Anyway.... 
    Also, when the Verizon Internet Security Suite is scanning while I am online, most of the websites stop responding or it takes so long to open a website that I just shut down.
    I am at a loss here and getting ready to trash the thing. Could it be the router, or something else?  I have cleaned up, done defragging, deleted cookies and so forth.
    Thanks for reading and for any advice that someone could give to a not so technical user.  

    Sounds like you've done much of what would cover a slow computer. if the system, booted into either Windows Vista or Windows 7 isn't feeling slow it's most likely something up with the Internet connection. We'll sort that out for you and also work with anything that needs to be tweaked on the PC to get the most out of the service.
    We've established one thing already. Your line is synchronized properly for 3Mbps service, which is 3360/864kbps. This also signifies you are on G.DMT ADSL or another ADSL1 standard. ADSL2 and ADSL2+ modes display different sync rates for the same speed.
    If you could, can you supply to us a Speed Test from this website: http://web100.rit.edu:7123/  (needs Java) or for that matter, use http://www.speedtest.net/ to supply a speed test? The second site is easier to get results from as it gives you an image link. The first test is often more reliable for testing but you'll need to take a screenshot as lately they haven't been allowing Clipboard access due to tightened browser security.
    In addition, if your service feels slow, does it only feel like this during the evening and night time hours or is it like this constantly, even in the morning?
    Since you mentioned the machine getting really slow during a VISS scan, that makes me wonder: How much RAM is installed in your system? To find out go to the Start Menu, right click on Computer and then click on Properties. Under "Memory" it will display how much memory the system has, and if there is a certain amount of memory that can be used. Knowing that bit of information would be good too since a virus scan should not cause slow net performance unless the machine itself is loaded down. Your browser should be operating in RAM and using limited disk resources (which virus scans consume, due to Disk I/O).
    ========
    The first to bring me 1Gbps Fiber for $30/m wins!

Maybe you are looking for