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
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
Write a program (preferably in Java) that, given an arithmetic expression, first transforms it to a...
Write a program (preferably in Java) that, given an arithmetic expression, first transforms it to a postfix form, and then computes its value (by using stack-based algorithms). Assume that all the numbers in the arithmetic expression are one-digit numbers, i.e., each of these numbers is either 0, or 1, or 2, ..., or 9. For example, your program should correctly process expressions like 2+3*4, but there is no need to process expressions like 11+22.
For the following types of values, designate discrete variables (D) and continuous variables (C): (a) weight...
For the following types of values, designate discrete variables (D) and continuous variables (C): (a) weight of the contents of a package of cereal, (b) diameter of a bearing, (c) number of defective items produced, (d) number of individuals in a geographic area who are collecting unemployment benefits, (e) the average number of prospective customers contacted per sales representative during the past month, (f) dollar amount of sales.
Analyze following logic expression representing a digital system, Z = (A+C)(A'+D')(B'+C'+D) Identify the 0-hazards and write...
Analyze following logic expression representing a digital system, Z = (A+C)(A'+D')(B'+C'+D) Identify the 0-hazards and write down the logic expression for the implementation of static free circuit. Note that you would be requiring three additional loops in K-map.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT