1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Simora [160]
3 years ago
5

The area of a rectangle is the rectangle's length times its width.

Computers and Technology
1 answer:
aliya0001 [1]3 years ago
4 0

Answer:

Following are program to this question:

#include <iostream> //defining header file  

using namespace std;  

int main() //defining main method

{

   double len1,len2,wid1,wid2,area1,area2; //defining double variable

   cout << "Enter first rectangle length: "; //print message

   cin >> len1;//input first rectangle length value

   cout << "Enter first rectangle width: ";//print message

   cin >> wid1; //input first rectangle width value

   area1 = len1*wid1; //calculate area and holds its value  

   cout << "Enter second rectangle length: ";//print message

   cin >> len2; //input second rectangle length value

   cout << "Enter second rectangle width: ";//print message

   cin >> wid2; //input second rectangle width value

   area2 = len2*wid2; //calculate area and holds its value  

   if(area1 > area2) //check condition area1 value is greater then area2

   {

    cout << "First rectangle area value is greater";//print message

   }

   else if(area2 > area1)//check condition area2 value is greater then area1

   {

       cout << "Second rectangle area value is greater";//print message

   }

   else //else block

   {

       cout << "both rectangle area is same";//print message

   }

   return 0;

}

Output:

Enter first rectangle length: 3

Enter first rectangle width: 5

Enter second rectangle length: 5

Enter second rectangle width: 3

both rectangle area is same

Explanation:

The description of the above program can be described as follows:

  • In the given code, the double variable is declared, which is "len1, len2, wid1, wid2, area1, and area2". In the next line, a message is a print, that accepts "len1 and wid1" value in the next line, the area variable is used that calculates area1.
  • In the next step, the "len2 and wid2"  variable is used, that accepts values and calculates its area, and in the next line, the conditional statement is used that checks its value.
  • In the if the block it uses both area1 and area2 value, that checks area1 is greater then area2, it is will print first rectangle area is greater.  
  • Otherwise, it will go to else if block, that checks area2 is greater then area1, it is will print second rectangle area is greater.  In the else section, it will print both equal areas.

You might be interested in
A wide variety of "apps" are available to customize devices. Which category of app does word processing software fall into? Ente
kkurt [141]
 word processing falls into the productivity education application.
6 0
3 years ago
How to cheat on asseeprep
Burka [1]
Just do it just look up the answers mate
6 0
2 years ago
All websites with medical information should be considered credible.
larisa [96]
No, this is not true. WebMD is a great example asking you of simple symptoms that you may be facing and your results could present an apparent fatal disease. This constantly scares the population of netizens whenever they would want a quick diagnosis online through these medical information sites. The best solution to your symptoms is to visit your family doctor or a licensed physician who will give you proper diagnosis checking your vital signs and other related information. Do not always trust the internet and the information it gives you as a user you must take the information with discretion before reacting inappropriately. 
3 0
2 years ago
Read 2 more answers
Does nest cam outdoor connect to a security camera prewire
yawa3891 [41]
Answer: hi there! Have a good day/night :))
6 0
2 years ago
Create a class called StockTester that has the following fucntionality. a. Create a main method with an ArrayList named dataStoc
myrzilka [38]

Solution :

public class $\text{Stock}$ {

private $\text{String}$ stockName, $\text{purchaseDate}$;

private $\text{int}$ nShares;

private $\text{double}$ price;

 

public $\text{Stock}()$

{

this.stockName = "";

this.purchaseDate = "";

this.nShares = 0;

this.price = 0.0;

}

public Stock(String stockName, String purchaseDate, int nShares, double price) {

this.stockName = stockName;

this.purchaseDate = purchaseDate;

this.nShares = nShares;

this.price = price;

}

public String getStockName() {

return stockName;

}

public void setStockName(String stockName) {

this.stockName = stockName;

}

public String getPurchaseDate() {

return purchaseDate;

}

public void setPurchaseDate(String purchaseDate) {

this.purchaseDate = purchaseDate;

}

public int getnShares() {

return nShares;

}

public void setnShares(int nShares) {

this.nShares = nShares;

}

public double getPrice() {

return price;

}

public void setPrice(double price) {

this.price = price;

}

 

public String toString()

{

return("Stock name: " + this.stockName + "\nPurchase date: " + this.purchaseDate

+ "\nNumber of shares of stock: " + this.nShares + "\nPrice: $" + String.format("%,.2f", this.price));

}

 

public void printStock()

{

System.out.println("Stock name: " + this.stockName + "\nPurchase date: " + this.purchaseDate

+ "\nNumber of shares of stock: " + this.nShares + "\nPrice: $" + String.format("%,.2f", this.price)

+ "\n");

}

}

StockTester.java (Driver class)

import $\text{java.io.}$File;

import $\text{java.io.}$File$\text{NotFound}$Exception;

import $\text{java.util.}$ArrayList;

import $\text{java.util.}$Scanner;

$\text{public}$ class StockTester {

 

private static final String FILENAME = "StockInfo$.$csv";

 

public static $\text{void}$ main($\text{String}[]$ args)

{

ArrayList$$ dataStock = $\text{readData}$(FILENAME);

 

System.out.println("Initial stocks:");

for(Stock s : dataStock)

s.printStock();

 

System.out.println("Adding a new Stock object to the list..");

Stock newStock = new Stock("Gamma", "03/01/20", 100, 50.5);

dataStock.add(newStock);

 

System.out.println("\nStocks after adding the new Stock..");

for(Stock s : dataStock)

s.printStock();

 

Stock targetStock = dataStock.get(3);

double reqReturn = requiredReturn(targetStock, 4000, 3);

System.out.println("Required rate of return = " + String.format("%.2f", reqReturn) + "%");

}

 

private static ArrayList<Stock> readData(String filename)

{

ArrayList<Stock> stocks = new ArrayList<>();

Scanner fileReader;

try

{

fileReader = new Scanner(new File(filename));

while(fileReader.hasNextLine())

{

String[] data = fileReader.nextLine().trim().split(",");

String stockName = data[0];

String purchaseDate = data[1];

int nShares = Integer.parseInt(data[2]);

double price = Double.parseDouble(data[3]);

 

stocks.add(new $\text{Stock}$(stockName, $\text{purcahseDate}$, nShares, price));

}

fileReader.close();

}catch(FileNotFoundException fnfe){

System.out.println(filename + " cannot be found!");

System.exit(0);

}

return stocks;

}

 

private static double requiredReturn(Stock s, double targetPrice, int years)

{

double reqReturn;

 

double initialPrice = s.getPrice() * s.getnShares();

reqReturn = ((targetPrice - initialPrice) / initialPrice * years) * 100;

 

return reqReturn;

}

}

3 0
2 years ago
Other questions:
  • an object or device outside the computer, that one would plug into a port to control the functions of a computer are?
    9·2 answers
  • What is a VIN and what role does it play during a criminal investigation? Explain how a VIN could help in a bomb and/or arson ca
    12·1 answer
  • 14<br> Select the correct answer.<br> Which activity is a marketing technique?
    9·1 answer
  • Emerson needs to tell his browser how to display a web page. Which tool will he use?
    8·2 answers
  • WILL GIVE BRAINLIEST ANSWER!!!<br><br> How do you manage your screen time?
    8·2 answers
  • A user calls to complain that her computer is behaving erratically. Some days it functions correctly, and other days, it crashes
    15·1 answer
  • Is iphone battery being draned if plugged into car charger when listening to podcasts
    6·1 answer
  • What happened to the ten commandments tablets.
    9·1 answer
  • You hide three worksheets in a workbook and need to unhide them. How can you accomplish this?.
    11·1 answer
  • How would you use keywords and Boolean operators to help you with a web search?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!