Question

In: Computer Science

write a program that evaluates the following arithmetic expression: ((A+B)/C)*((D-A)+E). Assign test values to the variables...

write a program that evaluates the following arithmetic expression: ((A+B)/C)*((D-A)+E). Assign test values to the variables and display the resulting value.

Solutions

Expert Solution

CPP code :

#include <iostream>

using namespace std;

int main() {
float A,B,C,D,E,f,g,h;
cout << "enter the value of A: " << endl;
cin >> A;
cout << "enter the value of B: " << endl;
cin >> B;
cout << "enter the value of C: " << endl;
cin >> C;
cout << "enter the value of D: " << endl;
cin >> D;
cout << "enter the value of E: " << endl;
cin >> E;
f=(A+B)/C;
g=(D-A)+E;
h=f*g;
cout <<"value of the arithmatic expression (A+B)/C)*((D-A)+E) is:" << h;
}

Output

Java code:

import java.util.Scanner; // scanner library to take input from user
public class Arithmaticoperation // class
{
public static void main(String args[]) //main method
{
float A,B,C,D,E,f,g,h; // variable declaration

System.out.println("Enter the value of A: \n"); //taking inpput from user
Scanner in = new Scanner(System.in);
A = in.nextFloat(); // storing to A
System.out.println("Enter the value of B: \n"); //taking inpput from user
B = in.nextFloat(); //storing to B
System.out.println("Enter the value of C: \n"); //taking inpput from user
C = in.nextFloat(); //storing to c
System.out.println("Enter the value of D: \n"); //taking inpput from user
D = in.nextFloat();
System.out.println("Enter the value of E: \n"); //taking inpput from user
E = in.nextFloat();
  
f=(A+B)/C;
g=(D-A)+E;
h=f*g; // calculating expression
  

System.out.println("value of the arithmatic expression (A+B)/C)*((D-A)+E) is:" + h);
}
}

Output

NOTE : if you need code in any other language u can comment on it ,it will be provided.


Related Solutions

: In this assignment you will write a C++ program that evaluates an arithmetic expression (represented...
: In this assignment you will write a C++ program that evaluates an arithmetic expression (represented with an infix notation), then outputs this expression in prefix form and also outputs the result of the calculation. The program will first convert the input infix expression to a prefix expression (using the Stack ADT) and then calculate the result (again, using the Stack ADT). The details are provided in the following sections.
Write an ASM program that evaluates the following expression, using variables: Z = (-A - B)...
Write an ASM program that evaluates the following expression, using variables: Z = (-A - B) - (-C - D) 1. Declare and initialize the memory variable A to 32-bit signed integer value 543210 and variable B to 16-bit signed integer value -3210. 2. Declare the memory variables C and D and read in their values from the keyboard as 32-bit signed integer value 43210 and 8-bit signed integer values -10, respectively. a. You should display a message asking for...
Write an ASM program that evaluates the following expression, using variables: Z = (-A - B)...
Write an ASM program that evaluates the following expression, using variables: Z = (-A - B) - (-C - D) 1. Declare and initialize the memory variable A to 32-bit signed integer value 543210 and variable B to 16-bit signed integer value -3210. 2. Declare the memory variables C and D and read in their values from the keyboard as 32-bit signed integer value 43210 and 8-bit signed integer values -10, respectively. a. You should display a message asking for...
Lab 7. Boolean Expressions a) Write a program that evaluates the following expressions. Assign reasonable values...
Lab 7. Boolean Expressions a) Write a program that evaluates the following expressions. Assign reasonable values to the variables. Print the results. a<b≥c , √a−7 b2 ≠c , d∨e∧f , a<b∨¬d ∧means and, ∨means inclusive or, ¬ means not. b) Write a program that asks a user whether he or she wants to become a Java programmer and determines if the user typed “yes” (Print true if yes and false otherwise.) Don't use the if statement here
1.Write a new expression similar to the following :     E1= a+b*c+(d*e+f)*g a)Convert your expression to...
1.Write a new expression similar to the following :     E1= a+b*c+(d*e+f)*g a)Convert your expression to postfix form. b) Trace the algorithm Postfix on slide 38 using your expression. 2.Write a new expression similar to the following :    E2= 6*((5+(2+3)*8)+3) Convert your expression to postfix form. Trace EvalPostfix algorithm on slide 53 using your expression. 3.Write a program that receives some input values and     a ) Displays these values by pointers, c)Displays their memory addresses.
Write a program that inputs the values of three Boolean variables, a, b, and c, from...
Write a program that inputs the values of three Boolean variables, a, b, and c, from a “cin” operator (user gives the values be sure to prompt user for what they have to give!). Then the program determines the value of the conditions that follow as true or false. 1. !(a&&b&&c) && ! (a||b||c) 2. !(a||b)&&c Output should include the values of a,b,c ie 0 or 1 in the patterns that follow reflecting the Boolean logic being tested. Where “True”...
Write a c statement to declare variables of primitive data types, and assign values to the...
Write a c statement to declare variables of primitive data types, and assign values to the variables. Use common control structure in c, such as if, switch, break, for, while statements. Write a c program that takes command line parameters, and perform some computation based on the command line input. Write c statements to generate random number within a certain range. Write a c statement to declare array variables of primitive data types, and assign values to the elements of...
C++ OOP •Write a program that evaluates a postfix expression (assume it’s valid) such as 6...
C++ OOP •Write a program that evaluates a postfix expression (assume it’s valid) such as 6 2 + 5 * 8 4 / - •The program should read a postfix expression consisting of digits and operators into a string. •The algorithm is as follows: 1.While you have not reached the end of the string, read the expression from left to right. –If the current character is a digit, Push its integer value onto the stack (the integer value of a...
Consider the cross: A/a; b/b; C/c; D/d; E/e x A/a; B/b; c/c; D/d; e/e a) what...
Consider the cross: A/a; b/b; C/c; D/d; E/e x A/a; B/b; c/c; D/d; e/e a) what proportion of the progeny will phenotypically resemble the first parent? b) what proportion of the progeny will genotypically resemble neither parent?
What are the values of a, b, c, d, and e after the following statements? int...
What are the values of a, b, c, d, and e after the following statements? int a = 5, b = 2, c = 8, d = 7, e = 4; int x = c - b + a; a = a + x - d; b = c * d - x; c = e + a / 2; d = x - c * a; e = x + d - c;
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT