c++ program homework help?

I am having trouble with some of my homework.

We began this new section last week, and I was out of class from strep throat.

I have all my other questions completed and part of some of theses questions. I am having trouble getting these question answered. Any help i would greatly appriciete it.

If you can please post your answer and if you can explain it step it will be great.

1. Write a program that prompts the user to input a number. The program should then output the number and a message saying whether the number is positive, negative, or zero.

2. Write a program that prompts the user to input three numbers. The program should then output the numbers in ascending order.

3. Write a program that prompts the user to input an integer between 0 and 35. If the number is less than or equal to 9, the program should output the number; otherwise, it should output A for 10, B for 11, C for 12, .... Z for 35. Hint use static_cast<char>

5. A box of cookies can hold 24 cookies and a container can hold 75 boxes of cookies. Write a program that prompts the user to enter the total number of cookies, the number of cookies in a box, and the number of cookie boxes in a container. The program then outputs the number of boxes and the number of containers to ship the cookies. Note that each box must contain the specified number of cookies and each container must contain the specified number of boxes. If the last box of cookies contains less than the number of specified cookies, you can discard it, and output the number of leftover cookies. Similarly, if the last container contains less than the number of specified boxes, you can discard it, and output the number of leftover boxes.

11. A bank in your town updates its customers accounts at the end of each month. The bank offers two types of accounts: savings and checking. Every customer must maintain a minimum balance. If a customers balance falls below the minimum balance, there is a service charge of 10.00 for savings accoutns and 25.00 for checking accounts. If the balance at the end of the month is at least the minimum balance, the account receives interest as follows:

a. Saving accounts receive 4% interest.

b. Checking accounts with balances of up to 5,000 more than the minimum balance receive 3% interest; otherwise the interest is 5%.

Update:

Hey I was talking to my teacher about what I was missing, and he says I cant be using arrays and that we dont learn that until a couple more chapters. He says Im supposed to be using "If" and "else"

I've only been in this class for a couple of months. so yeah

5 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    1.

    int a;

    printf("enter num: "); scanf("%d",&a);

    printf("your number is %d. ",a);

    if(a < 0) printf("it is a negative number"); /*if number is less than 0 then its negative*/

    elseif(a>0) printf("it is a positive number"); /*if number is greater than 0 then its positive*/

    else printf("its zero"); /*we are only left with 1 more condition and that is 0*/

    2.

    int a, num[3], temp;

    for(a=0;a<=2;a++){printf("enter num%d: ",a);scanf("%d", num[a]);} /* loop to get 3 numbers and asign it to an array*/

    /*arrange in ascending order*/

    for(a=0;a<2;a++){

    for(b=a;b<=2;b++){

    if(num[a]>num[b]){

    temp=num[a];

    num[a]=num[b];

    num[b]=temp;}}}

    for(a=0;a<=2;a++)printf("\n%d",num[a]); /* output ascending order*/

    im still working on the other questions... sorry, i have to squeeze it between office works.. and i dont have c++ here, so please tell me if there are any errors... hope this helps!

    **** additional answers:

    5.

    int total, cooksinbox, boxes, boxincont, containers, leftcookies, leftboxes;

    printf("Enter total # of cookies: "); scanf("%d",&total);

    printf("Enter # of cookies/box: "); scanf("%d",&cooksinbox);

    printf("Enter # of boxes/container: "); scanf("%d",&boxincont);

    boxes=total/cookinbox; /* get how many boxes to be used */

    leftcookies = total % boxes; /* get leftovers cookies */

    container=boxes/boxincont; /* get how many containers */

    leftboxes = boxes % container; /* get leftover boxes*/

    printf("\nWith %d cookies, %d boxes are used with %d cookie-leftovers.",total, boxes, leftcookies);

    printf("\n%d containers are used with %d box leftovers.",containers, leftboxes);

    with your number 11 question, can you elaborate further? how do we know if its saving or check? is it based on a database or user will enter it? as well as the acount balance. have you started on it? you can post your code then i'l edit it for you.

    thanks!

    • Commenter avatarLogin to reply the answers
  • 4 years ago

    1. Bad programming, not knowing whta you are doing. 2. Syntax errors won't compile, logical errors will, but produce results that aren't what you are expecting. 3. Another post will have these. 4. C is older, not visual. Visual Basic isn't as powerful, but is easier and more popular in industry.

    • Commenter avatarLogin to reply the answers
  • Anonymous
    4 years ago

    Fonctions.

    • Commenter avatarLogin to reply the answers
  • Badsha
    Lv 4
    1 decade ago

    Solution for 1

    void main()

    {

    int a;

    printf("Enter any no.");

    scanf("%d",&a);

    if(a==0)

    printf("\n The no is zero");

    else if (a<0)

    printf("\n The no. is negative");

    else

    printf("\n The no. is positive");

    }

    Solution for 3

    void main()

    {

    int a;

    printf("Enter a no.");

    scanf("%d",&a);

    if(a<=9)

    {

    printf("%d",a);

    }

    else

    printf("%c",char(a));

    }

    • Commenter avatarLogin to reply the answers
  • How do you think about the answers? You can sign in to vote the answer.
  • 1 decade ago

    what school do you got to?

    and send to my email.

    • Commenter avatarLogin to reply the answers
Still have questions? Get your answers by asking now.