Output.txt: Rectangle(1) - Area = 12.0 %3D Rectangle(2) - ERROR, this is square not rectangle! Rectangle(3) - Area = 8.0 Rectangle(4)- ERROR, Invalid width or length number!!

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section7.5: Case Studies
Problem 7E: (File creation) Write a C++ program that creates an array containing the integer numbers 60, 40, 80,...
icon
Related questions
Question
Please help with simple java code i/o
ReferenceS
Mallings
Enable Editing
can contain viruses. Unless you need to edit, it's safer to stay in Protected View.
University of Bahrain
College of Information Technology
Department of Computer Science
ITCS114: Introduction to Computer Science
Assignment 4: Files
Write a java program that reads the width and length for a set of rectangles (unknow numbers)
from input file (input.bxt). The program should compute the area for each rectangle and store the
result in a file called (Output.txt).
Also, you need to consider the following cases:
1- If width and length are equal, then a message (This is a square) should be displayed instead of
area.
2- If width or length has negative values, then invalid message should be displayed instead of
I
the area.
Input.txt:
6.0 2.0
4.0 4.0
2.0 4.0
-4.0 5.0
Output.txt:
Rectangle(1) - Area = 12.0
Rectangle(2) - ERROR, this is square not rectangle!
Rectangle(3) - Area = 8.0
Rectangle(4) - ERROR, Invalid width or length number!!
Transcribed Image Text:ReferenceS Mallings Enable Editing can contain viruses. Unless you need to edit, it's safer to stay in Protected View. University of Bahrain College of Information Technology Department of Computer Science ITCS114: Introduction to Computer Science Assignment 4: Files Write a java program that reads the width and length for a set of rectangles (unknow numbers) from input file (input.bxt). The program should compute the area for each rectangle and store the result in a file called (Output.txt). Also, you need to consider the following cases: 1- If width and length are equal, then a message (This is a square) should be displayed instead of area. 2- If width or length has negative values, then invalid message should be displayed instead of I the area. Input.txt: 6.0 2.0 4.0 4.0 2.0 4.0 -4.0 5.0 Output.txt: Rectangle(1) - Area = 12.0 Rectangle(2) - ERROR, this is square not rectangle! Rectangle(3) - Area = 8.0 Rectangle(4) - ERROR, Invalid width or length number!!
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT