Can any one help me??

I need the full code for this question. Can any please give me the solution?
Write a java program which does the following:
1.     Declares 2,  1 -D integer arrays called M and N, with 16 elements each.
2.     Populates M and N using Scanner.
3.     Prints the sum of all the elements in M
4.     Prints the maximum and the minimum values in M
5.     Counts the number of even and the number of odd values in M.
6.     Copies the distinct values in M into another array called P, and then print the values in P.
7.     Prints all the elements in P which are not in N.I have tried doing it a bit but got errors.
import java.util.Scanner;
public class hw4 {
public static void main(String[] args) {
     Scanner kb = new Scanner(System.in);
     int[] M = new int[16];
     int[] N = new int[16];
     System.out.println(" Enter elements of M:");
     for(int i=0; i<16; i++) {
               M[i] = kb.nextInt();
     System.out.println("\n Enter elements of N:");
     for(int j=0; j<16; j++) {     
               N[j] = kb.nextInt();
     for(int k=0; k<16; k++) {
          int sum = M[k] + N[k];
     System.out.println("Sum: " +sum);     
     max(M);     
     System.out.println("Max: " +maximum);          
public static int max(int[] t) {
    int maximum = t[0];
    for (int i=1; i<t.length; i++) {
        if (t[i] > maximum) {
            maximum = t;
return maximum;
}Please help me...continue the program. Thanks!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

JaVa_MAsTeR wrote:
I need the full code for this question. Can any please give me the solution?One bit of advice, never ask for "full code" as that marks you as possibly being lazy. I'm sure that's not what you intended, but the full code is your responsibililty, not ours. Also, when asking for free advice, it's best not to put stipulations on that advice. It can be thought of by some as being kind of rude.
Anyway, your sum doesn't sum M. What you are doing is adding each element in M array to the same element in the N array, and each time you over-write the previous result in Sum. To add the elements of M together, you need to add each element to the sum variable. Inside of the for loop, something like so:
mySum = mySum + arrayElementor to shorten:mySum += arrayElement[i]Edited by: Encephalopathic on Dec 24, 2007 9:20 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Can any one help me in fi/sl extraction

    can any one help me in fi/sl extraction.i am not able to get data in cube please send me screen cut of fi/sl extraction.
    Edited by: chaitanya pissay on Apr 11, 2008 7:26 AM

    Hi Chaitanya,
    Check here........
    FI-SL Extraction
    FI /SL extraction
    http://help.sap.com/saphelp_nw70/helpdata/EN/04/e04c40cc538437e10000000a155106/frameset.htm
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/FISL/FISL.pdf
    Fi_SL data model
    http://help.sap.com/saphelp_bw32/helpdata/en/af/16533bbb15b762e10000000a114084/frameset.htm
    Regards,
    Vijay.

  • Can any one help me in this code

    Hi all,
    I have created a selection screen and my aim is to display some fields or some block dynamically by choosing some radio button is it possible.
    can any one help me in this.
    REPORT  z_g_test.
    TABLES: spfli,sbook,sscrfields.
    SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:s_carrid FOR spfli-carrid.
    SELECTION-SCREEN END OF BLOCK 1.
    PARAMETERS:rad1 RADIOBUTTON GROUP g1 USER-COMMAND us1,
               rad2 RADIOBUTTON GROUP g1 DEFAULT 'X' .
    SELECTION-SCREEN BEGIN OF SCREEN 001 as subscreen ."WITH FRAME TITLE text-002.
    SELECT-OPTIONS: s_fldate FOR sbook-fldate.
    SELECTION-SCREEN END OF SCREEN 001.
    DATA ok_code LIKE sy-ucomm.
    INITIALIZATION.
    START-OF-SELECTION.
      SELECT * FROM spfli WHERE carrid IN s_carrid.
      ENDSELECT.
    END-OF-SELECTION.
      WRITE:spfli-carrid.
    AT SELECTION-SCREEN.
      CASE sscrfields-ucomm.
          WHEN'US1'.
    *      call screen 001 starting at 55 40.
      ENDCASE.
    Is i am going on the right way
    Regards,
    Lisa.
    Message was edited by: Lisa Roy
    Message was edited by: Lisa Roy
    Message was edited by: Lisa Roy

    This is what I meant. Copy this and try as it is and see if it serves your purpose.
    REPORT ztest1 .
    TABLES: spfli, sscrfields, sbook.
    SELECTION-SCREEN BEGIN OF TABBED BLOCK tabb1 FOR 4 LINES.
    SELECTION-SCREEN TAB (25) tabs1 USER-COMMAND ucomm1
                         DEFAULT SCREEN 001.
    SELECTION-SCREEN TAB (25) tabs2 USER-COMMAND ucomm2
                         DEFAULT SCREEN 002.
    SELECTION-SCREEN END OF BLOCK tabb1.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE abc.
    PARAMETERS: p_date LIKE sy-datum.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF SCREEN 001 AS SUBSCREEN .
    SELECT-OPTIONS: s_fldate FOR sbook-fldate.
    SELECTION-SCREEN END OF SCREEN 001.
    SELECTION-SCREEN BEGIN OF SCREEN 002 AS SUBSCREEN .
    SELECT-OPTIONS:s_carrid FOR spfli-carrid.
    SELECTION-SCREEN END OF SCREEN 002.
    INITIALIZATION.
      tabs1 = 'Search by flight date'.
      tabs2 = 'Search by flight number'.
      abc   = 'Some other parameters'.
    AT SELECTION-SCREEN OUTPUT.
      CASE sscrfields-ucomm.
        WHEN 'UCOMM1'.
          tabb1-prog = sy-repid.
          tabb1-dynnr   = 001.
          tabb1-activetab = 'TABS1'.
        WHEN 'UCOMM2'.
          tabb1-prog = sy-repid.
          tabb1-dynnr   = 002.
          tabb1-activetab = 'TABS2'.
      ENDCASE.

  • Can any one help me to code a browser

    hi ,
    I am Anil, I am doing an application in java. it needs a browser as IE or Morzilla . i tried to implement the browser using jdic.
    i add jdic.jar files as a external jar file and added it to my project. when i run the program in eclipse it works fine. when i want to create a jar file to my application it shows the follwing error..
    when i click on that jar file , it shows a Java Virtual Machine Launcher dialog box and in that dialog box it shows error Could not Find the main class. Program will exit ..
    this is the error.
    can any one help me to over come the error or any alternative method to implement a browser..

    DarrylBurke wrote:
    Corss poster!
    [http://www.java-forums.org/advanced-java/30298-how-write-job-aggregator-java-j2ee.html]
    dbNot anymore, Fubarable has axed that thread.

  • Hello, every one. Over the last few days I haven't been able to download any app from the app store. can any one help me, please?

    Over the last few days I haven't been able to download any app. can any one help me, please ? thank you.

    Andrea...
    You posted in the "Using Mac App Store" forum but your profile indicates you are using an iPad so that's what I'll try helping you with.
    On the iPad tap Settings > General > Reset > Reset Network Settings
    Then restart the iPad.  Hold the On/Off Sleep/Wake button down until the red slider appears. Slide your finger across the slider to turn off iPhone. To turn iPhone back on, press and hold the On/Off Sleep/Wake button until the Apple logo appears.
    If you still can't download apps, the problem may be your Wi-Fi connection >  iOS: Troubleshooting Wi-Fi networks and connections

  • HT1338 When I connect my Macbook Pro to my Dell DLP projector, either via cable or wirelessly, I just see a dark screen with the mouse and mouse trails only, can any one help?

    When I connect my Macbook Pro to my Dell DLP projector, either via cable or wirelessly, I just see a dark screen with the mouse and mouse trails only, can any one help?

    jpmarkques post is a good start point, after folling his directions, you can try detect displays. Also try different rsolution and refresh rates.
    Most of the projectors I have used support a 1024X768 res.
    Youcan also try a pram reset if it still does not detect.
    Leave theproctor connected and powered up, power down the MBP.
    Power back up the MBP and hold the following keys before you hear the start up chime:
    Option, command, P,R (no commas) continue to hold these keys till you hear the start up chime 2 times.

  • Safari keeps crashing every time I try to open a link from a different application, i.e. Mail. The trouble report says that some problem occurs with libcooliris.dylib plug-in. Can any one help?

    Safari keeps crashing every time I try to open a link from a different application, i.e. Mail. The trouble report says that some problem occurs with libcooliris.dylib plug-in. Can any one help?
    Thanks!

    Dear Linc,
    Thank you for the advice, John Blanchard1  and Linc Davis
    As suggested in your reference thread I removed "/Library/Printers/hp/PDEs/hpPostScriptPDE.plugin" and the problem has been resolved.
    I am guessing the the plug-in for the hp printers got corrupted and effected every thing, or became unsuitable when I installed an Apple update. I would be most grateful if you can confirm how the problem was coursed so I can understand and learn from this experiance.
    Ash

  • Since itunes and apple tvs latest update I have had problem wtching movies on apple tv via my itunes can any one help, movie takes a very long time to load sometimes never, it use to work really well, whats going on please help?

    Since itunes and apple tvs latest update I have had problem wtching movies on apple tv via my itunes can any one help, movie takes a very long time to load sometimes never, it use to work really well, whats going on please help?

    You might find useful information in item D1 of Time Machine Troubleshooting.

  • Hello guys..!! I have got my new  iphone 4 2 days ago.The same day it got a problem of auto restart in every 1, to 2 minutes. I updated and restored it many times...but of no use... can any one help me how to solve this problem..!!

    Hello guys..!! I have got my new  iphone 4 2 days ago.The same day it got a problem of auto restart in every 1, to 2 minutes. I updated and restored it many times...but of no use... can any one help me how to solve this problem..!!

    Go to Settings/General/Reset - Erase all content and settings. the connecto to iTunes and restore as a New phone. Do not restore any backup. If the problem persists you have a hardware problem. Take it to Apple for exchange.
    This assumes that the phone is not hacked or jailbroken. If it is you will have to go elsewhere on the internet for help.

  • I am not able to register my Apple ID for iCloud and the error is "the maximum no of free accounts have been activated on this phone" can any one help me why I need to do

    I am not able to register my Apple ID for iCloud and the error is "the maximum no of free accounts have been activated on this phone" can any one help me why I need to do

    Sir, your Apple ID can be used as an iCloud account as well. They are both the same thing.
    You can learn more from --> Set up your Apple ID for iCloud and iTunes - Apple Support

  • Hi i am unable to send mail from yahoo mail id.can any one help on this?

    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    import java.io.*;
    import java.util.Properties;
    public class MailClient
      public void sendMail(String mailServer, String from, String to,
                                 String subject, String messageBody,
                                 String[] attachments) throws
    MessagingException, AddressException
             // Setup mail server
             Properties props = System.getProperties();
             props.put("mail.smtp.host", mailServer);
             // Get a mail session
             Session session = Session.getDefaultInstance(props, null);
             // Define a new mail message
             Message message = new MimeMessage(session);
             message.setFrom(new InternetAddress(from));
             message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
             message.setSubject(subject);
             // Create a message part to represent the body text
             BodyPart messageBodyPart = new MimeBodyPart();
             messageBodyPart.setText(messageBody);
             //use a MimeMultipart as we need to handle the file attachments
             Multipart multipart = new MimeMultipart();
             //add the message body to the mime message
             multipart.addBodyPart(messageBodyPart);
             // add any file attachments to the message
             addAtachments(attachments, multipart);
             // Put all message parts in the message
             message.setContent(multipart);
             // Send the message
             Transport.send(message);
         protected void addAtachments(String[] attachments, Multipart multipart)
                         throws MessagingException, AddressException
             for(int i = 0; i<= attachments.length -1; i++)
                 String filename = attachments;
    MimeBodyPart attachmentBodyPart = new MimeBodyPart();
    //use a JAF FileDataSource as it does MIME type detection
    DataSource source = new FileDataSource(filename);
    attachmentBodyPart.setDataHandler(new DataHandler(source));
    //assume that the filename you want to send is the same as the
    //actual file name - could alter this to remove the file path
    attachmentBodyPart.setFileName(filename);
    //add the attachment
    multipart.addBodyPart(attachmentBodyPart);
    public static void main(String[] args)
    try
    MailClient client = new MailClient();
    String server="pop3.yahoo.com";
    String from="[email protected]";
    String to = "[email protected]";
    String subject="Test";
    String message="Testing";
    String[] filenames = {"c:\\gopi.txt"};
    client.sendMail(server,from,to,subject,message,filenames);
    catch(Exception e)
    e.printStackTrace(System.out);     
    while compliling this one its compiled succesfully but i am getting exception at run time like..D:\mail>java MailClient
    Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/activation/re
    gistries/MailcapFile
    at javax.activation.MailcapCommandMap.loadFile(MailcapCommandMap.java:275)
    at javax.activation.MailcapCommandMap.<init>(MailcapCommandMap.java:128)
    at javax.activation.CommandMap.getDefaultCommandMap(CommandMap.java:44)
    at javax.activation.DataHandler.getCommandMap(DataHandler.java:136)
    at javax.activation.DataHandler.getDataContentHandler(DataHandler.java:568)
    at javax.activation.DataHandler.getContent(DataHandler.java:501)
    at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1253)
    at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2012)
    at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:1980)
    at javax.mail.Transport.send(Transport.java:97)
    at MailClient.sendMail(MailClient.java:35)
    at MailClient.main(MailClient.java:72)
    can any one help on this....plz
    thanks in advance
    Edited by: Konapalli.Gopi on May 20, 2010 5:42 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Something's wrong with your CLASSPATH.
    If you're not using JDK 6, you need to include activation.jar in your CLASSPATH.
    If you've got any other jar files that define the javax.mail.* or javax.activation.* classes
    in your CLASSPATH (such as javaee.jar or j2ee.jar), remove them.

  • Can any one help me to fix my ipod touch it wont recognized by my laptop and itunes its said usb not recognized itried all the tips like reboot and restore plshelp me thanks

    can any one help me to fix my ipod touch it wont recognized by my laptop and itunes its said usb not recognized its freeze iin display usb and itunes logo pls help me pls itried all the uninstall unknown device and reboot the ipod and restore pls help me thanks

    Try the suggestions found here: http://www.apple.com/support/ipodtouch/assistant/itunes/

  • I can no longer back up my iphone to my computer on selecting 'sync'. I can back up to iCloud but I get an error message telling me I cannot backup to my Mac. Can any one help? It's driving me crazy!

    I can no longer back up my iphone to my computer on selecting 'sync'. I can back up to iCloud but I get an error message telling me I cannot backup to my Mac. Can any one help? It's driving me crazy!

    Hello joelfromn. charleston,
    It seems you are unable to activate iMessage on a device with no carrier service. The following article provides information regarding activation issues:
    If you get an error when trying to activate iMessage or FaceTime - Apple Support
    Check your device settings
    Make sure that you’re connected to a cellular data or Wi-Fi network. If you're using an iPhone, you'll need SMS messaging to activate your phone number with iMessage and FaceTime. Depending on your carrier, you might be charged for this SMS.
    Go to Settings > General > Date & Time and make sure that your time zone is set up correctly.
    Thank you for contributing to Apple Support Communities.
    Cheers,
    Bobby_D

  • Hi, plz can any one help me that is there any way to locate or find the stolen ipon nano???

    hi, plz can any one help me that is there any way to locate or find the stolen ipon nano???

    Other than physically looking for it, no. It does not have WiFi.

  • HT204023 hi there can any one help me i have a iphone 5 but my mobile internet not working but i can connect to my wifi no bother

    hi there can any one help me i have a iphone 5 but my mobile data is not working but a can connect to my wifi no bother

    talk to your carrier about the data subscription and possible settings changes to their apn than

  • I'm not able to copy and paste files from my mac to hard disk and usb. I have tried dragging the items to those devices but it won't work. I also have tried copying and pasting those files onto those devices but that doesn't work too. Can any one help?

    I'm not able to copy and paste files from my mac to hard disk and usb. I have tried dragging the items I want to copy to those devices but it won't work. I also have tried copying and pasting those files onto those devices too but that doesn't work too. Can any one help?

    Hi BobRz
    Thanks for you suggestion but it didn't work - are there other ways for solving this problem? Or is it because my files that I want to copy and paste onto my hard disk etc are too big? (However there is space on my hard disk and it works on a PC)

Maybe you are looking for

  • 0CRM_SALES_ACT_1 Cancelled in Source System

    Hi, I'm having problems with a BI7 dataload, from our CRM source system, based upon the 0CRM_SALES_ACT_1 datasource. I've cleared down the data in my related InfoProviders, deleted all PSA requests and previous Delta Inits, and I'm now trying to load

  • How do i bring up list of music on my ipod shuffle

    I have a ipod shuffle and want to display my music list on screen so I can add or delete music

  • Error after updating NuGet package installer

    I am getting an error on my OdatService app after downloading the new nugget package in visual studio 2012 Nu Get Packages are missing form this solution   Click Restore to restore form your online package sources. When I click Restore I get the erro

  • Javascript issue for fragment in jspx page cannot find regionId

    I am using Jdev 11.1.1.4.0 When i am calling the javascript function its not able to find the region thus my component is not found in the jsff page. Please help !!! Below is my jspx page :- <f:view>     <af:document id="d1" title="Home Page" partial

  • ENTIRE screen goes grey when I use siri.

    Before ios7 when I held the home button to activate siri, I was still able to view the page that I was on. So, if there was a phone number that I needed siri to dial (I realize you can click on most phone numbers and iphone will ask whether you'd lik