What character you should use to create your output figure

Assignment Help JAVA Programming
Reference no: EM13886192

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

Reference no: EM13886192

Questions Cloud

Estimate expected changes in the magnitude : Determine two researchable hypotheses based on your research problem. For each hypothesis, identify the independent, dependent, and control variables. Moreover, estimate expected changes in the magnitude and relations between the dependent and ind..
Estimate the force needed to move the cylinder : SAE-10 oil at 20-C fills the gap between the moving 120-cm-long cylinder and the fixed outer surface. Assuming a zero pressure gradient, estimate the force needed to move the cylinder at 10 m=s. Assume a laminar flow.
The united states worker abuse of developing countries : Prepare the annotated bibliography on this Essay - The United States Worker Abuse of Developing Countries
Estimate the torque needed assuming a linear velocity profle : SAE-30 oil at 40-C fills the gap between the stationary plate and the 20-cm-diameter rotating plate shown in Fig. 7.15. Estimate the torque needed assuming a linear velocity profile if O ¼ 100 rad=s.
What character you should use to create your output figure : The char will be a single character and indicate what character you should use to create your output figure. You will write a program that reads from one file, interprets what it reads and writes to a second fine.
Estimate the flow rate and the maximum shear stress : Water at 20-C flows down an 80-m-wide parking lot at a constant depth of 5 mm. The slope of the parking lot is 0.0002. Estimate the flow rate and the maximum shear stress. Is a laminar flow assumption reasonable?
Describes the fundamental concept of uniformitarianism : Which of the following best describes the fundamental concept of uniformitarianism
What are prototyping''s advantages and disadvantages? : What are prototyping's advantages and disadvantages?
Calculate the flow rate and the pressure drop : Fluid flows in a horizontal channel that measures 1 · 40 cm. If Re ¼ 1500, calculate the flow rate and the pressure drop over a length of 10 m if the fluid is water at 20-C,

Reviews

Write a Review

JAVA Programming Questions & Answers

  The goal is to create a project that would let a user

the goal is to create a project that would let a user compute area and perimeter of a polygon. restrict the type of

  Program which evaluates a weighted average

Write a program which reads student names, social security numbers, and test scores from an input file named infile.

  Palindrome is a sequence of char that reads backward forwrd

A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554, and 11611. Write an application called Palindrome.java that asks the user t..

  Assume an ideal gas mixture is in contact with water

Assume an ideal gas mixture is in contact with water. Determine the equilibrium concentration of the contaminant in the liquid is the gas stream is composed of 200 ppm of benzene in air

  What command is used to create a java archive

What command is used to create a Java archive? Describe using an example.

  Creation of a virtual world java application

Implement classes that meet the given specifications of object instance variables and behaviors and create operative algorithms using sequential logic structures, decision control structures, and loops

  Java program to implement currency converter

Write a JAVA program that helps the user convert currency. The user will enter the amount in Kuwaiti dinars. The program will print the equivalent amount in US dollar and Euros count his change.

  Distance traveled modification

Distance Traveled Modification

  Java application to generate three-digit random number

Write a Java application that generates a 3-digit random number 100 times. Display the output for each of the generated numbers and the sum of all 100 numbers.

  Luminous jewels - the polishing game

Once a jewel type is removed from the necklace, all other instances of the same jewel type is treated as polished by the person who removed the jewel

  Implementing a binary tree write a generic implementation

Implementing a Binary Tree Write a generic implementation of a binary tree class using an internal node class TreeBinUMUC and NodeTreeBin

  Create a new child class and new driver program

In this assignment you will create a new child class and new driver program. Please review that example before continuing with this assignment. You should fully understand the shape program above

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd