Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

You will write a program that reads from one file, interprets what it reads and writes to a second fine.

There is an example input file in Moodle: infile.dat. You will need to copy those files onto your computer in the same folder that contains the main.cpp program for this project.

The program should then do the following things:

1) Open infile.dat for reading.
2) Open outfile.dat for writing.
3) Read the information on infile.dat, one line at a time, until the file is at EOF.
4) Interpret the information read and write the appropriate output on outfile.dat.
5) Close both files.

In Moodle there are example programs that open a file and read from it, write to it, or append to it. You should use these to give you an idea of how to do the file I/O portion of this exercise.

Each record (line) of infile.dat will have the following format: code char value1 value2(optional) The code will be from the following set of characters: D, R, S, T, E.

The char will be a single character and indicate what character you should use to create your output figure.

The values will be the size of the output figure. For D, S, and T, there will be only one value. For R, there will be two. E will have no additional values on its line.

End

If the code is an E, you are to end the program. Diamond

If the code is a D, you are to create a diamond of the char. Diamonds should always have an odd number for their dimension. For example, with the line

D ! 3

You should generate a diamond that looks like

  !
! ! !
  !

For the line D *5

You should generate a diamond that looks like

    *
  ***
*****
  ***
   *

Square

If the code is an S, you are to create a square of the char. For example, with the line S!3 You should generate a square that looks like

! ! !
! ! !
! ! !

For the line S@5

You should generate a square that looks like

@@@@@
@@@@@
@@@@@
@@@@@
@@@@@

Triangle

If the code is a T, you are to create a triangle of the char. For example, with the line T=3

You should generate a triangle that looks like

  =
 ==
===

For the line T^ 5

You should generate a triangle that looks like
    ^
   ^^
  ^^^
 ^^^^
^^^^^

Rectangle

If the code is an R, you are to create a rectangle of the char. Rectangles, have two values, rows and columns. For example, with the line
R a 2 4

You should generate a rectangle that looks like aaaa

aaaa

For the line R &6 3

You should generate a rectangle that looks like

&&&&&&

&&&&&&

&&&&&&

Notes to keep in mind:

• Before starting, think about what information you'll need to keep track of during

• The program will use a reading loop, some way to determine what code was entered, and a function to draw each shape. The function will need to have as parameters the character to use to draw the shape, the dimension(s) of the shape, and the ouput file to write it on.

• You should check for an improper file. That is, if you get an EOF when trying to read something, you should exit the program with an error message.

Example Input File T&4

S@6 Tx5
R *5 7 D-7 D +5
R =43 E

Evaluation

Before you submit your work, take a look at the evaluation criteria and make sure that your program meets them.

Attachment:- Main_.cpp

Java, Programming

  • Category:- Java
  • Reference No.:- M91560300
  • Price:- $50

Priced at Now at $50, Verified Solution

Have any Question?


Related Questions in Java

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As