I need some help with my homework, I've been taking a c++ course for like 7 weeks now and have been running into some problems that the teacher hasn't exactly been covering in class, my first program is just supposed to be a simple switch program, for some reason it's not solving it, I'm sure its something stupid I'm not seeing
Code:
#include <iostream>
using namespace std;
int main()
{
char opselect;
double fnum, snum;
cout << "Please type in two numbers ";
cin >> fnum >> snum;
cout << "Please select a code: ";
cout << "\n a add";
cout << "\n b multiply";
cout << "\n c divide";
cout << "\n";
cin >> opselect;
switch (opselect)
{
case 'a':
cout << "The sum of the numbers entered is " << fnum+snum << endl;
break;
case 'b':
cout << "The product of the numbers is " << fnum*snum << endl;
break;
case 'c':
cout << "The dividend of the numbers is" << fnum/snum << endl;
break;
}
system("pause");
return 0;
}
also I can't just use int opselect cause we have to use char for some reason, the next thing is a little weirder i guess, we never covered this, we are supposed to put an algorithm into a program, it has 4 steps to convert a numeric value to a certain amount of decimal places, but step three is to get rid of all decimal places, I don't know how I would do that in c++
Code:
#include <iostream>
using namespace std;
int main()
{
double money, interest, total;
cout << "Enter an amount of money: ";
cin >> money;
intrest = 0.08675;
total = money * interest;
total = total * (10*10); // step one
total = total + 0.5; // step two
// step three would be to drop all decimal places from total
total = total / (10*10); // step four finishes it
cout << "The interest is: " << total << endl;
system("pause");
return 0;
}
I hate to ask these questions but me and my friends cant really figure out how to do it, my teacher wasnt to much help and his response to second program was "just put it directly into the program, thats all i can really tell you" and thanks for any help in advance