Hi, I'm new to programming and I'm doing a course in uni. I'm currently using "Dev-C++". I've been away on holidays and haven't been able to grasp the work we're doing now. I would really appreciate it if any of you C++ programming geniuses helped me with my work as I'm in a troubling situation with no idea what to do. If anyone is so helpful enough to help me with some of the questions or as much as you can then I will be so grateful. I will use this help to learn and understand more about C++ but for now I just need help on these questions.
Thanks.

Q.1

Option A
Using parentheses, rewrite the following expression to indicate the correct order of evaluation. Then evaluate the expression, assuming a=5, b=2, and c=4.

a % b * c && c % b * a

Option B
Determine the value of the following expression, assuming a=5, b=2, c=4, and d=5.

d % b * c > 5 || c % b * d < 7

Option C
Using parentheses, rewrite the following expression to indicate the correct order of evaluation. Then evaluate the expression, assuming a=5, b=2, and c=4.

b % c * a || a % c * b

Q.2
Option A
Write a C++ program to compute and display a person's weekly salary as determined by the following expressions:

If the number of hours worked is less than or equal to 40, the person receives $8.00 per hour; otherwise, the person receives $320.00, plus $12.00 for each hour worked over 40 hours.

The program should request the hours worked as input and should display the salary as output.

Option B
Write a C++ program that accepts a character using the cin object and determines whether the character is a lowercase letter. A lowercase letter is any character that is greater than or equal to 'a' and less than or equal to 'z'. If the entered character is a lowercase letter, display the mssage The character just entered is a lowercase letter. If the entered letter is not lowercase, display the message The character just entered is not a lowercase letter.


Q.3

This question is in regard to the C++ program

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
double monthlySales, income;

cout << "Enter the value of monthly sales: ";
cin >> monthlySales;
if (monthlySales >= 50000.00)
income = 375.00 + .16 * monthlySales;
if (monthlySales >= 40000.00 && monthlySales < 50000.00)
income = 350.00 + .14 * monthlySales;

// simplified here from the one in the textbook
if (monthlySales < 40000.00)
income = 200.00 + .03 * monthlySales;

cout << "\n\n\The income is $" << income << endl;

return 0;
}

and the C++ program

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
double monthlySales, income;

cout << "Enter the value of monthly sales: ";
cin >> monthlySales;

if (monthlySales >= 50000.00)
income = 375.00 + .16 * monthlySales;
else if (monthlySales >= 40000.00)
income = 350.00 + .14 * monthlySales;

// simplified here from the one in the textbook
else
income = 200.00 + .03 * monthlySales;

cout << "The income is $" << income << endl;

return 0;
}

Option A

Will these two programs produce the same output?
Which program is better? Why?
Draw the flow chart for the first C++ program.

Option B

Will these two program produce the same output?
Which program is better? Why?
Draw the flow chart for the second C++ program.

Q.4

Option A, B
For the following C++ program

#include <iostream>
using namespace std;

int main()
{
int num = 0;
while (num <= 20)
{
num++;
cout << num << " ";
}

return 0;
}

determine the total number of items displayed, and the first and last numbers printed. Draw the flow chart for the C++ program, and then desk-check the program for the first 5 steps and the last 3.

it became too classic :P

which one you cant finish and want help?cause i assume you started them and you had trouble in the proccess,am i right?

We aren't going to do your coursework for you. In fact, the site's rules, which you obviously didn't read, forbid it. If we did the work for you, what would you learn? Answer: You would learn nothing.

If you start your work, and can provide evidence that you have tried to complete it on your own, we may "coach" you through your tough spots. What we will not do though is hand you all of your solutions on a silver platter.

i am some months new in that forum and it had created me the sense that the posts that people asking, to do homework for them will became more than the threads that are actually helpful.

i am some months new in that forum and it had created me the sense that the posts that people asking, to do homework for them will became more than the threads that are actually helpful.

The problem isn't that the OP is asking for help, that's why the site is here. The problem is that the OP is asking us to do their work for them. Not only that, they're asking us to do half of their coursework so that they can get "caught up" after being "on holiday" (which is read: "skipping class").

If you look at any other thread where the OP produced the same type of post, they all got the same slap on the wrist. Many of them, after realizing the error of their ways, return and produce a proper post, then they solve their problem and actually learn something in the process.

I really am having trouble and I have attempted some of the questions. For example in question 2 I have managed this but am not sure if I am right. If any of you can please give me a full display of the program then I would appreciate it but this is my answer to question 2:

Option A
//input hours worked hr
int salary;
if(hr<=40 && hr>0)
salary=hr*4;
else
salary=320+((hr-40)*4);
//print salary
Option B
//input character ch
if(ch>='a' && ch<='z')
//print

Also for question 3 I think they produce the same output but I am not sure which program is better and why as well as how to draw a flow chart.

Finally, for question 4, I believe there's 21 items? I just need help with the flow chart and desk checking. Also have no idea for question 1.

I really am trying. Thanks.

i know what you mean,was just an observation cause i entered the site to learn since i am self teaching from a book,and i check the forum almost daily for my questions and new threads and most are that kind.


the good part is that i copy them as exercise and i do them by myself at home :D since are university exercises :P

but anyway :P

Hope I can get help and thanks if you do :).

I hate to sound desperate but I really need help. Mainly for question 1, 3 and 4. If anyone can give me ideas and possible solutions then I will be grateful :).

Thanks.

commented: Shameless Bump. -1

ok question 4
actually you have to do nothing except read the program...

your teacher ask to write something like that --> 1,4,6,9,12,15,20 (this is wrong its an example)
example : first number is " this one "
last number is " this one "

flow chart i think its the thing with cube and squares.

ask you to show the values of num ,what is the first value and what is the last value...

not being an expert if you cant ask the specific problem,isnt cause of being away in holidays

and i dont know what she means about desk check :P english isnt my native laguage

extra tip: http://www.google.com/imgres?imgurl=http://www.breezetree.com/flow-charts/basic-flowchart.png&imgrefurl=http://www.breezetree.com/flow-charts/flowchart.htm&usg=__6SwX9aMMOB0PU7EsjrC7L4gc5EA=&h=473&w=419&sz=13&hl=en&start=0&sig2=FjD0mwiNptrxakPlJfrhjg&zoom=1&tbnid=LWCEo40wa-lOGM:&tbnh=144&tbnw=128&ei=_CyjTcGPJcqy8gP72tGoAw&prev=/images%3Fq%3Dflow%2Bchart%26um%3D1%26hl%3Den%26client%3Dfirefox-a%26sa%3DN%26rls%3Dorg.mozilla:en-US:official%26biw%3D1440%26bih%3D771%26tbm%3Disch&um=1&itbs=1&iact=rc&dur=76&oei=_CyjTcGPJcqy8gP72tGoAw&page=1&ndsp=32&ved=1t:429,r:2,s:0&tx=28&ty=76

Show us your work/answers first. We're not going to just give them to you.

Q1 is almost as easy as it comes:

  1. Add parentheses
  2. perform substitution
  3. evaluate
  4. Record your result.

Q2 was posted by someone else just this morning, so this work isn't to awfully old.

Q3 is simply a hand trace, then use Word, Publisher, Visio, or RAPTOR to replicate the code.

Q4 Same as Q3

There is nothing difficult or complex about any of these. Have you read your book, at all?

I have managed this for question 1, is it correct?

Option A


a=5, b=2, and c=4.

a % b * c && c % b * a

5 % 2 * 4 && 4 % 2 * 4
((5 % 2 * 4) && (4 % 2 * 4)) on the left they are all of the same priority so only need the single set of parents.
Now do them left to right
((1 * 4) && (0 * 4))
((4) && (0))
(4 && 0) Anything not 0 is true
true && false. As I stated above in an AND statement everything must be true for the statement to be true.
So this gives you false.

Also I just need more specifics for question 3 and 4. I know that the programs produce the same output but don't know which program is better. Also need more help on flow charts for both question 3 and 4 as well as desk checking.

Thanks.

Show us your work/answers first. We're not going to just give them to you.

Q1 is almost as easy as it comes:

  1. Add parentheses
  2. perform substitution
  3. evaluate
  4. Record your result.

Q2 was posted by someone else just this morning, so this work isn't to awfully old.

Q3 is simply a hand trace, then use Word, Publisher, Visio, or RAPTOR to replicate the code.

Q4 Same as Q3

There is nothing difficult or complex about any of these. Have you read your book, at all?

Can you link me to the person who posted question 2 in the morning. I would like a solution to this question.

Thanks.

Can you link me to the person who posted question 2 in the morning. I would like a solution to this question.

Thanks.

No, if I do, I may as well give you the solution myself, which I'm sure you've gathered I won't.

Can I get a hint for question 2 please? Also, the flow chart questions for 3 and 4? Don't know how to do flowcharts. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.