This code is what I've already written. It satifies the first example in my instructions but I don't know where or how to fit the if, if-else statements and among other things that I might be leaving out that I need to complete the code and comply with my instructions. Please help me. Thanks!
Program:
#include<iostream>
#include<limits>
#include <cmath>
using namespace std;
int main() {
char OP; // variable declaration
float num1, num2; // variable declaration
cout<<"Enter left operand:";
cin>>num1;
if(cin.fail())
{
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(),'\n');
cout<<"Invalid left operand."<<endl;
return 0;
}
cout<<"Enter operation:";
cin>>OP;
if(OP!='B'&&OP!='b'&&OP!='|')
{
cout<<"Enter right operand:";
cin>>num2;
if(cin.fail())
{
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(),'\n');
cout<<"Invalid right operand."<<endl;
return 0;
}
}
switch (OP) // check the operator
{
case '+' : // if operation +
cout<<"Result = "<<num1+num2<<endl;
break;
case 'A' : // if operation +
cout<<"Result = "<<num1+num2<<endl;
break;
case 'a' : // if operation +
cout<<"Result = "<<num1+num2<<endl;
break;
case '-': // if operation -
cout<<"Result = "<<num1-num2<<endl;
break;
case 'S': // if operation -
cout<<"Result = "<<num1-num2<<endl;
break;
case 's': // if operation -
cout<<"Result = "<<num1-num2<<endl;
break;
case '*': // if operation *
cout<<"Result = "<<num1*num2<<endl;
break;
case 'm': // if operation *
cout<<"Result = "<<num1*num2<<endl;
break;
case 'M': // if operation *
cout<<"Result = "<<num1*num2<<endl;
break;
case '/': // if operation /
cout<<"Result = "<<num1/num2<<endl;
break;
case 'D': // if operation /
cout<<"Result = "<<num1/num2<<endl;
break;
case 'd': // if operation /
cout<<"Result = "<<num1/num2<<endl;
break;
case 'B': // if operation /
cout<<"Result = "<<abs(num1)<<endl;
break;
case 'b': // if operation /
cout<<"Result = "<<abs(num1)<<endl;
break;
case '|': // if operation /
cout<<"Result = "<<abs(num1)<<endl;
break;
default:
cout<<"Unknown operation: "<<endl;
break;
}
return 0;
}
Output:
This code is what I've already written. It satifies the first example in my instructions but...
I need help with this c++ code. This is my first computer
science course. I have not learned arrays but I am learning
vectors. I am also required to write this code without do loops or
any other form of advanced coding technique. Please help me figure
out this code using the basic coding techniques that you would find
in an introduction to cs. Thank you for your help, I don't even
know where to start :)
I've been asking a lot of people where to start learning java web development, I already know core java (Threading,Generics,Collections, a little experience with (JDBC)) but I do not know JSPs and servlets. I did my fair share of development with several web based applications using PHP for server-side and HTML,CSS,Javascript,HTML5 for client side. Most people that I asked told me to jump right ahead to Hibernate while some told me that I do not need to learn servlets and...
(I've already seen the example "My Name is Slim Shady" I was hoping for another type of example. Deciding which codons to edit is confusing to me.) A) Use the genetic code to encode a secret message. Use the standard amino acid code as capital letters, as in A for alanine, Y for tyrosine, to make a message in English. Convert the message into a hypothetical mRNA sequence. Write down the mRNA sequence and translate the DNA. The message must...
this assingent is to pseudocode, i have instructions
and the example my teacher had given me for this, could i have some
assistance, i need to do this in netbeans IDE and i need to use the
scanner method as well and i need to pass both.
Overview: This assignment will allow you to use pseudocode to implement the program to see the value in planning first, coding later. While coding is the glamorous part of the job, software development is...
Hello I need help turning my code into a GUI applicaiton please. What I have for code and the requirements are below. Please please help, I will be so greateful. This is my last assignment of my school and I'm just so burnt out mentally that I don't know where to start and my teacher is always to busy to help. Thank you so so so much! -----Code------ private void CalculateSC(ActionEvent event) { if(amount < 10){ chargeAmount = 1; }else...
It isn't very clear to me what I'm supposed to do. I've learned
how to do trial balance & financial statements but when I add
things up here they clearly don't match. However, the ones where
they only post on one side my answers are right and where I get
postings on both sides my answers are incorrect.
Your answer is partially correct. Calculate the account balance for the following accounts: Cash Cr. Dr. 510 8,890 820 505 9,100 6,885...
"basic stamp 2" I’m having a hard time making a code with conditional statements. Please can you help me out Basically it is Since I have three options which are A or B or C I want to to pick let’s say B, so that means I want to open just this one. But I can’t seem to master the IF and ELSE codes as I know I need this ones in the loop Please provide me the code will...
Hi, I need help understanding a concept in my Assembly Language (MIPS) class. Can someone please explain the following to me: 3) Implementing Control Structures – Know how to write if-then or if-then-else equivalent statements in assembly as well as loops. This is a concept that is going to be asked on my exam. There's no real solution to this question, but I will rate whomever helps me understand this material. An example would be GREATLY appreciated.
Language is in C. Need help troubleshooting my code Goal of code: * Replace strings with a new string. * Append an s to the end of your input string if it's not a keyword. * Insert a period at the end, if you have an empty input string do not insert a period Problems: //Why does my code stop at only 2 input strings //If I insert a character my empty string case works but it's still bugged where...
"basic stamp 2" I’m having a hard time making a code with conditional statements. Please can you help me out Basically it is Since I have three options which are A or B or C I want to to pick let’s say B, so that means I want to open just this one. But I can’t seem to master the IF and ELSE codes as I know I need this ones in the loop Please provide me the code will...