Write a program that asks the user to enter two numbers,obtains the two numbers from the user and prints the sum,product,difference, and quotient of the two numbers

Answers

Answer 1
Answer:

Answer:

#include<iostream>

using namespace std;

//main function

int main(){

   //initialization

   float a1,a2;

//display the message

cout<<"Enter the first number: ";

   cin>>a1;  //store the value

   cout<<"Enter the second number: ";

   cin>>a2;   //store the value

   //display the calculation result

   cout<<"The sum is: "<<a1+a2<<endl;

   cout<<"The Subtraction is: "<<a1-a2<<endl;

   cout<<"The product is: "<<a1*a2<<endl;

   cout<<"The Quotient is: "<<a1/a2<<endl;

}

Explanation:

Create the main function and declare the two variables of float but we can enter the integer as well.

display the message on the screen and then store the input enter by the user into the variable using the cin instruction.

the same process for second input as well, display the message and store the input.

after that, print the output of the calculation. the operator '+' is used to add the two numbers like a1+a2, it adds the number stored in the variable.

similarly, the subtraction operator is '-', product '*' and quotient operator '/'.

and finally, we get the desired output.


Related Questions

In the 2018-2019 softball season, Allison hit the ball 28 out of 67 times, this included fouls. What was her percentageof misses?
One advantage of the Second generation of programming language is that it is machine dependent. True or False
(Palindrome integer) Write the methods with the following headers // Return the reversal of an integer, i.e., reverse(456) returns 654 public static int reverse(int number) // Return true if number is a palindrome public static boolean isPalindrome(int number) Use the reverse method to implement isPalindrome. A number is a palindrome if its reversal is the same as itself. Write a test program that prompts the user to enter an integer and reports whether the integer is a palindrome.
Subtract (100000)2 from (111)2 using 1s and 2s complement method of subtraction​
software that interprets commands from the keyboard and mouse is also known as the? A. desktop B. Operating system C. operating disk D. hard drive

Consider the following definition of a recursive method. public static int mystery(int[] list, int first, int last) { if (first == last) return list[first]; else return list[first] + mystery(list, first + 1, last); } Given the declaration int[] alpha = {1, 4, 5, 8, 9}; What is the output of the following statement? System.out.println(mystery(alpha, 0, 4)); a. 1 b. 18 c. 27 d. 32

Answers

Answer:

c. 27

Explanation:

  • In recursion method, a method calls itself until a condition becomes true and returned back. In mystery(), at first time, first is 0 and last is 4. Condition is checked and 0!=4 so else part is executed in which again mystery is called with first as 1 and last 4. This will go again and again until first=4.
  • When first=4 it is also equal to last so if part is executed and alpha[4] is returned which is 9, now it comes alpha[3] +9 which is 8+9 =17 .
  • It is returning values to its previous calls that is why it will reduce to alpha[0]+alpha[1]+alpha[2]+17 which is nothing but sum of all elements of a alpha
  • Then, 1+4+5+8+9=27.

Write an application that calculates and displays the amount of money a user would have if his/her money could be invested at 5% interest for one year. Create a method that prompts the user for the starting value of the investment and returns it to the calling program. Call a separate method to do the calculation and return the result to be displayed. Save the program as Interest.java

Answers

Answer:

// Application in java.

// package

import java.util.*;

// class definition

class Main

{

  // method for calculating interest

  public static float calculateInterest(float start_bal,float i_Rate)

  {

  // calculate return

     float return_Amount=start_bal+(start_bal*(i_Rate/100));

     // return

    return return_Amount;

  }

// main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

         // scanner Object to read the input

         Scanner sc = new Scanner(System.in);

         // variables

         float start_bal;

         float i_Rate=5;

         // ask to enter start money

        System.out.print("Enter start money:");

        // read start money

        start_bal=sc.nextFloat();

        // call the function and print the return amount

        System.out.println("5% interest earned on $" + start_bal + " after one year is $" + calculateInterest(start_bal,i_Rate));

   }catch(Exception ex){

       return;}

}

}

Explanation:

Declare and initialize interest rate with 5.Then read the start money from user.Then call the method calculateInterest() with parameter start_bal and i_Rate.It will calculate the return amount after 1 year.Print the returned amount in main method.

Output:

Enter start money:1500

5% interest earned on $1500.0 after one year is $1575.0

What type of object can offer the mosteffective way to display data and calculations in a presentation?

Answers

I think the answer would be a chart. It is important for researchers to use the most effective chart to display their data results.

A graph or a table.

You can use a graph or a table to make the point muchstronger than just describing the data. A graph can be used to represent one ofmore sets of data graphically. A table in this case as compared to a graph isless effective because it only shows the data whereas the graph shows an interpretationof data. However, you can use a table from an excel sheer to enter raw data and make some complex andsimple calculations.






Give a non-network example of hierarchical addressing and discuss how it reduces the amount of work needed in physical delivery. Do not use the postal service, or the telephone network..

Answers

HIERARCHICAL EXAMPLE.

Many examples of hierarchical addressing exists which reduces the amount of work needed in locating or in delivering,and one of such examples is the 'sorting of books in a library'.

Looking at a library having books kept randomly on any stack and shelf,it will make it difficult finding any book easily or locating any book of a specific genre.so,to avoid such problems, books are orderly sorted in a library and each book is given or has a unique identification number.

Books that has the same or related subject are kept in the same stack and books of the same genre are also kept together.

In a library,there are many stacks having different rows.

Take for an example; If one need to find a book on computer network,the user can search for the books in stacks of books that are related to Computer Science instead of searching the whole library for the book.

So,the hierarchical addressing saves lots of work and also time required for searching a specific book in the library.

9 Which of these words is used to begin a conditional statement? ​

Answers

Answer:

The word used to begin a conditional statement is if.

Explanation:

In the syntaxes of most (if not all) programming languages, the word if is used to begin any conditional statement.

Take for instance:

Python:

if a == b:

   print("Equal")

C++:

if(a == b)

cout<<"Equal";

Java:

if(a==b)

System.out.print("Equal")

The above code segments in Python, C++ and Java represents how conditional statements are used, and they all have a similarity, which is the "if" word

Integer userNumber is read from input. Write a while loop that multiplies userNumber by 4, updating userNumber with the product, and outputs the updated userNumber, followed by a newline. The loop iterates until userNumber is greater than or equal to 40.Ex: If the input is 25, then the output is:

100

import java.util.Scanner;

public class ProductCalculator {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int userNumber;

userNumber = scnr.nextInt();
while(userNumber >= 40){
userNumber = userNumber * 4;
System.out.println(userNumber);
}
Java. What am I doing wrong? It's not giving an output.

}
}

Answers

Change this line;

  • while(userNumber >= 40)

with;

  • while(userNumber <= 40)

The loop will never start because userNumber is not already greater than 40.