Thread: Programming question

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    4

    Programming question

    Ok guys, I could use a little programming help. I have two programming problems that I have to figure out, and I've been pounding my brain for the last two weeks trying to solve them. I'm not a programmer, basic reason why. If anyone can help me on this, I can't do anything for ya except give my thanks. Here's one program:

    I. Write a program that will input non-negative integer and call a function DWARF to determine if the integer is DWARF or not.

    Output Specifications

    Print
    The factors of N:
    The sum of its factors are :
    Half of N is
    N is DWARF

    Sample Input

    Input N? 6

    Sample Output
    Factors are 1,2,3
    The sum of its factors are 1+2+3=6
    Half of the number is 3
    6 is DWARF

    Sample Input
    Input N ? 9

    Sample Output
    Factors are 1,3
    The sum of its factors are 1+3=4
    Half of number is 4.5
    9 is DWARF

    The other is this
    II. ARRAY - An instructor gave a multiple choice test, which consists of 5 questions, each of which is answered by a choice of one of the #s 1 - 5. The program should grade the test. If the student choice is 1, give 1 point. If the choice is 2, give 2 points, and so on. Otherwise no point is given. The programe should compute the average score of the student on the given test.

    Input Specifications
    Write a program that will accept student name and the set of their test answer.

    Output Specifications
    Print the name of the student, his/her total score, and the set of their test answer.

    Sample Input
    Enter Student Name: Mae
    Enter Answer 1? 2
    Enter Answer 2? 3
    Enter Answer 3? 5
    Enter Answer 4? 5
    Enter Answer 5? 4

    Sample Output
    Mae, your total score is 19 and your average score is 3.8.

    I hope you guys can understand all this. I'm not that good in programing, but if anyone can give me something that I can put into turbo C++ to make these work, I will owe you lunch if I could give it to ya. Thanks

    Kev

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Do your own homework.
    Woop?

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    4
    I did. It didn't work.

  4. #4
    ---
    Join Date
    May 2004
    Posts
    1,379
    If you are not a programmer then why are you programming?
    I think you signed up for the wrong classes

  5. #5
    Registered User
    Join Date
    Sep 2005
    Posts
    4
    Long story, but basically the school I'm at has me in what they call non-traditional studies. Basically, I'm on my own. I don't go to class or nothing. I can contact the professor if I need help. The problem is that the professor they gave me is always busy. So, I'm pretty much own my own. I tried all the online tutorials, but they only teach so much. I'm really in a bind here. And if you're wondering why I don't transfer, it's because the gov. is paying for the class, and I have to pass or else. Like I said, long story. Once I finish the semester, I can get back into traditional classes. I just have to finish this semester.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > I did. It didn't work.
    So post what you did achieve, then we can perhaps help you to fix it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Sep 2005
    Posts
    4
    Ok, I'll try to post it in about another 24 hours. I'm in the Phils, so I'm about to sleep. I'm still working on it. I'll send what I have tommorow, k? Thanks. By the way, im not asking anyone to do the work for me, just help me understand it better. Thanks again!

  8. #8
    Registered User
    Join Date
    Mar 2005
    Posts
    22
    I hear McDonalds is hiring.

  9. #9
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    I gotta say that sucks, but considering its a free course.. You could have read about.com, cprogramming.com, cpluscplus.com, and etc. tutorials and have gotten how to do this. If you need that much explanation, and considering its a semester, I recommend getting 2 C++ books, it WILL be necessary in your situation. Accelerated C++ and C++ Primer Plus are my recommendations.

    The factors of N:
    The sum of its factors are :
    Half of N is
    N is DWARF
    - Use cin >> to put N into a variable.
    - Make an array arrayofFactors to hold the arrays, allocated at say 15 values of int.

    - To calculate the factors you could use a for loop that runs while some variable is > 1, and < N / 2.
    Code:
    e.g. for(int i = 1; i <= N / 2 && i > 0; i++)
    - Then inside the for loop you use the modulus operator % that checks if N % i is equal to 0.
    Code:
    e.g. if(N % i == 0) { 
    arrayofFactors[j] = i; 
    j++; }
    - The j there is the number of factors found so far, and obviously arrayofFactors is the ones found.
    - Simply use a for loop and print the array of factors.

    - Simply use a for loop to add the array of factors together.
    e.g. factorSum += arrayofFactors[i];

    - To calculate half of N simply: variable / 2, and cout << that.
    N is DWARF? just cout << the variable.

    Some of that syntax might be incorrect , how about you try posting ANYTHING you can figure out for yourself, and dont just try the first part and if you cant do it give up, skip to the next part, and post everything and describe what you cannot figure out how to do.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM