Need help with a Folder type problem , i dont have any ideas how to do it RRS feed

  • Question

  • A store sells N models of mobile phones. The data on the number of phones of each model sold during the year are stored in the two-dimensional T-array with N lines and 12 columns. The value of T and i represents the number of (i)) sold in month ((j)).


    Write a program that will calculate the total number of phones sold during the year and the phone model from which no copies have been sold. The program must contain a subprogram with the name NT. The NT program receives as a parameter the whole value (((i))) - the indentation of a T-line and returns an integer value - the sum of the elements in the line ((i)) of the T . Input ::: The TEL.IN file contains a whole number N-number of marketed mobile models (1 <= N <= 100). Count N lines containing 12 integers separated by space - the elements of the T-array. The number with the index j in the line i + 1 of the file is the value of the element T [i, j] (T [i, j <100]).


    The TEL.OUT file contains two lines. The first line contains a whole number - the total number of phones sold during the year. The second line contains whole numbers separated by space - the index of the models of mobile phones that have not been sold If there are no such models, then the second line contains the expression: Are not.

    Thursday, May 10, 2018 8:09 PM

All replies

  • Since this is obviously a homework problem, no one here is going to write the code for you.  You just need to divide the problem up into smaller steps that you know how to do.

    First, you'll need to read the TEL.IN file, one line at a time.  Since this is homework, you must have been told how to read a file line by line.  You'll need to keep track of the line number, so you know which phone "index" N you're on.

    Once you have the line in a string, you'll pass it to the poorly named NT function.  That function will have to chop the line up into individual numbers (the String.Split function will help here), convert those split-up strings to integers, and add them all up.

    Back in the main program, you add the result of NT to your running total of all phones, and if the value is zero, you'll add that index to a list of phones that did not sell.

    Finally, you can output the total of all phones, and the list of phones that did not sell.

    Tim Roberts, Driver MVP Providenza & Boekelheide, Inc.

    Thursday, May 10, 2018 9:55 PM
  • Ask specific questions instead of asking how to write the entire program.

    Sam Hobbs

    Friday, May 11, 2018 3:52 AM