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...
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 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...
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;
Let A = {a, b, c, d} and B = {b, d, e}. Write out all...
Let A = {a, b, c, d} and B = {b, d, e}. Write out all of the elements of the following sets. (a) B ∩ ∅ (b) A ∪ B (c) (A ∩ B) × B (d) P(A\B) (e) {X ∈ P(A) | |X| ≤ 3}
Write a program that performs the following two tasks in java Reads an arithmetic expression in...
Write a program that performs the following two tasks in java Reads an arithmetic expression in an infix form, stores it in a queue (infix queue) and converts it to a postfix form (saved in a postfix queue). Evaluates the postfix expression. Use linked lists to implement the Queue and Stack ADTs. DO NOT USE BUILT IN JAVA CLASSES
Given the following knowledge base: a <- b^c. b <- d^e. b <- g^e. c <-...
Given the following knowledge base: a <- b^c. b <- d^e. b <- g^e. c <- e. d. e. ƒ <- a^g. Which of the following would be the trace of resolved atoms assuming a bottoms-up proof procedure? Select one: a. {a,b,c,e,g} b. {a,b,c,e,d} c. {g,e,b,e,c,a} d. None of these options Constraint Satisfaction Problem (CSP) is consists of a set of _________________. Select one: a. Variables, heuristics, and solutions b. Variables, domains, and backtracking c. Variables, domains, and constraints d....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT