Posts

Showing posts with the label C-Plus-Plus

[SOLVED] Representation and manipulation of rational numbers in C++

Task is to define a class to represent and manipulate rational numbers (fractions), so that by simply changing the type of n1 and n2 to Rational the program will compute fractional arithmetic expressions such as these: 1/2 + 1/3 // answer: 5/6 1/3 - 1/4 // answer: 1/12 2/3 * 4/5 // answer: 8/15 3/7 / 2/3 // answer: 9/14 Download the file fractions_0.zip, which contains the calculator code and a skeleton version of the Rational class. The class defines (but doesn't fully implement) appropriate constructors to initialise instances of Rational, extract and insert operators for input and output of Rational values, and of course arithmetic operators to compute the results. Get your solution now  Buy now

[SOLVED] Count number of word from the .txt file in Java full source code

Your task is to write a program, words, that reports information about the number of words read from its standard input. For example, if the file qbf.txt contains the text the quick brown fox jumps over the lazy dog then running the program with is input redirected to come from that file will report 9 words $ words < qbf.txt   Total: 9 Automatic Testing   This task is available for automatic testing using the name words. You can run the demo using demo words and you can test your work using try words <<filename.    Background Use the following skeleton for the program: Level 1: The getopt function (#include <unistd.h) provides a standard way of handling option values in command-line arguments to programs. It analyses the command-line parameters argc and argv, looking for arguments that begin with '-'. It then examines all such arguments for specified option letters, returning individual letters on successive calls and adjusting the variable optind to i...

[SOLVED] Assignment 2: Rolosort in C++ with header file implementation

A Rolodex is a rotating file, usually used to record business contact information. Cards are inserted in alphabetic order by name. You operate the Rolodex by rolling it forwards or backwards until you find the information you need (or find the place where a new card should be added). Task  Your task is to create a class that simulates a Rolodex, then use it to implement a word-sorting program. The program starts with an empty Rolodex, then reads words from standard input and adds a card for each word in the appropriate position to maintain overall sorted order. To find the correct position, the Rolodex is rolled either backwards or forwards from the current card. When all input has been processed, the program moves the Rolodex to the beginning and then outputs each word in order, one per line.   Download the file rolosort_0.zip, which contains a basic version of the program and a skeleton version of the Rolodex class. The class has methods for rotating the Rolodex forwards and...

Geometer y and pricing inheritance program in C++ complete source code

A class is a programmer-defined data type that describes what an object of the class will look like when it is created. It consists of a set of variables and a set of functions. A class is repository of functions that any main program may use. In this project you will create two classes and two main drivers to test the classes. Part I Part I will produce 2 files. Geometry.h file is the Geometry class with its members and functions. main cpp file tests all the code in the Geometry class. The textbook examples place the class code in the same file as the main function, but your code will be more re-usable if the class is defined in a separate file – Geometry.h . The header file will need to be included in the program as you did in the Airline Problem and the array.h file. The final version of the Geometry class (Geometry.h) will include: Three constructors:  Constructor 1 – receives 2 integer values for length and width. (rectangle) Calls checkNum to validate each value. ...

Blob Finder implementation in C++ Assignment - 4 COP3010 Programming I in C/C++

Description: This assignment will not be very much code but can be very complex in execution. There are many places where a small error can not only be catastrophic but be very difficult to detect. In this assignment you will be working with reading in text files into multi-dimensional arrays, passing 2d arrays as parameters and using recursive functions. You will write a program to read in a file and find out how many groupings (blobs) of characters there are in the file. The image below is a sample input file. Note that it contains 6 groupings of characters or blobs. A character is part of a grouping or blob if it touches another character in the grouping on 1 of 8 positions around it. Notice that one of the groupings or blobs is located inside of another. You will open a file called blob.txt which will be provided to you. The file will contain exactly 20 records each of which is exactly 70 characters long. Your program can make the assumption that both the file name and size...

CS 222 Homework Assignment 6 ASCII File I/O

Introduction For this assignment, you will perform basic ASCII file Input and Output. Your program will read a series of questions from an input file, present them to the user, get the user's responses to the questions, and write both the questions and the responses to an output file. Specifications You program will begin by prompting the user to enter two filenames. The first filename will be the input file that contains the questions. The second filename will be the output file where the questions and responses will be written. Once the filenames are known, the program will open the two files, one for input and one for output. Your program will then enter a loop which will read each question from the input file, print the question to the console, and get the user's response to the question from the console. It will then write both the question and response to the output file. Your program will continue to do this until there are no more questions to be read from the i...

Pocker Game in C Programming - 300698 Operating Systems Programming (Advanced) – 300943

1 Introduction Operating Systems have a need for extremely compact data structures, as often these need to be stored wholly in memory. Examples of this are free memory lists, page tables and disk space bitmaps. This  practical Case Study will refresh your knowledge of bit operations, necessary to manipulate such compact data structures. We will use a simple variant of the card game poker as the inspiration for our compact data structure. In this exercise, you will model a deck of playing cards as a bit 1eld. Only six bits arerequired to fully describe a card, two for the suit and four for the value. An extra bit as been added to the structure to encode the colour of the card. A second bit 1eld will be used to store the number of pairs contained in a hand. Read this section fully before attempting any of the exercises. These instructions contain some background information, the task to perform, sample code and some system documentation extract. 2 Structure of the bit 1elds ...

C++ Project - Binary Search Tree Problems, finding height, number of nodes and BST cloning

Binary Search Tree Implementation + Full DocumentationThis programming assignment simulates the use and functionality of binary search trees (BST) by comparing statistics over several simulations. Start the random number generator at the current time stamp -- similar or the same as srand(time(0)). Initialize variables to be used in the program’s final report. Define a struct node with four fields: node * left, * right; int data; and int frequency. Frequency means the number of times the specific data value was placed into the tree. So, instead of having a BST with the same data values, count the number of times (more than zero) that the data value was placed into the tree. Run the following 1000 times: Start with an empty binary search tree. Load 5000 integers with values between 0 and 1023 into the BST. Without changing that tree (Call it T1, here), create another empty BST, say T2 and load all the data from T1 into T2 in such a way that T2 is “balanced.” Gather the followin...

Assignment 4 – Priority Queue in C++

Description: Implement a priority queue capable of determining what order a list of peopleshould be served given a numeric value. The highest priority should be given topersons with larger values (ordered largest to smallest). The priority queue shouldbe written using a C++ class, named PQueue, and the queue itself should beimplemented as a linked list similar to how we implemented queues/stacks inlecture.The following classes should be defined by your program:class Person : Used to store information about each personclass PQueue : Priority queue used to serve peopleThe following public functions need to be implemented:Person::Person( int, string ) : Initialize the personPQueue::PQueue( void ) : Initialize the priority queuebool PQueue::empty( void ) : Test whether queue is emptyint PQueue::size( void ) : Return sizePerson* PQueue::front( void ) : Access next nodePerson* PQueue::back( void ) : Access last nodevoid PQueue::enqueue( Person* ) : Insert nodevoid PQueue::dequeue( void ) :...

Circle Class - Area, Diameter, Circumference, Radius Implementation in C++ - HJ Soft

Project Specifications  Write a C++ program that will use a class called Circle that has the following member variables: radius: a float pi: a float initialized with the value 3.14159. The class should have the following member functions: constructor - sets the radius value = 0.0. setRadius - a mutator function for the radius variable. getRadius - an accessor function for the radius variable. getArea - returns the area of a circle, which is calculated as: area = pi * radius * radius getDiameter - returns the diameter of a circle, which is calculated as: diameter = radius * 2 getCircumference - returns the circumference of the circle, which is calculated as circumference = 2 * pi * radius Write a program that demonstrates the Circle class by asking the user for the circle's radius, creating a Circle object, and then reporting the circle's area, diameter, and circumference with 2 decimal places each. Get your project now Buy now

Passenger Seats Assigning Program full implementation in C++ - HJ Soft

Write a C++ program to assign passenger seats in an airplane. Chesapeake Airlines is a small commuter airline with seats for 36 passengers in 9 rows of 4 seats each. See the sample display below for a layout of the plane. The user enters the row (1 – 9) and the seat (A – D). The program checks the array to see if the seat is available. An X in the array indicates the seat is not available.If the seat is available, assign an X to that position in the array. If it’s unavailable, display a message to the passenger. There are 3 ticket classes:Row 1 = First ClassRows 2-4 = Business ClassRows 5-9 = Coach *Note that the rows are 0-8 in the C++ program.Use the classCtr array supplied in the header file to keep track of how many seats in each class are purchased.Continue processing requests until the user enters -1 for the row. After -1 is entered for the row, display number of seats sold. percentage occupied. sales report. You need to include the following functions in your program...

C++ - Game of Dungeons and Dragons complete implementation with header files

1.0 Overview In the popular role-playing, the game of Dungeons and Dragons players move from room to room in a dungeon where they encounter creatures, treasure, and various obstacles. The underlying functionality of such a computer game lies in the gaming engine. This Statement of Work presents the requirements for a "Scenario Mapping and Player Movement" class for a gaming engine. 2.0 Requirements The student shall define, develop, document, prototype, test, and modify as required the software system.  2.1 Functional Requirements 2.1.1 The software shall be capable of representing the layout for a role-playing game scenario as a graph implemented as an adjacency matrix. The scenario will typically be an inside location such as a dungeon or castle divided into some rooms. For this implementation, it will be assumed that the number of rooms will be 20.  2.1.2 The scenario graph shall be implemented as a class called GameGraph (defined in files GameGraph.h andGameGraph.cp...

CS222 Project 1 The Game of Korona és Horgony - Dice Rolling Game

Project Description: For this project, you will be creating a program to play a dice game known in Hungary as Korona és Horgony. The rules are fairly simple. Three dice, each containing six different symbols on each face are used. A mat, also containing the same six symbols is on the table. The player makes bets by placing wagers on one or more of the six symbols. The dice are then thrown. If any of the dice show the symbol on which a bet has been placed, the banker pays the player the amount of his stake for each die  showing that symbol. In other words, if only one of the dice shows the symbol, the player is paid even money (1:1). The player is paid 2:1 if two dice show the symbol, and 3:1 if all three dice show the symbol. If the symbol does not show up, the player loses any bets placed on that symbol. Although the symbols on the dice can be figures such as a bear, a cat, a gypsy wagon and so on, you will use the numbers 1-6, found on a typical die, for your program. Your ...

CS 211 Lab 5: Output, Inheritance, Censorship

CensoredWriter Overview Occasionally in history there has arisen the need to censor communications. An automatic means of doing this is to scan output and block or replace certain key words that appear. We will set up a class CensoredWriter which performs this task: any output that contains a specified string pattern will have the pattern replaced by a censor string. The solution will involve Making CensoredWriter a child class of PrintWriter CensoredWriter will then have print and println methods CensoredWriter will change what the print and println methods do: it will transform input to them. Transformations will be done in a special transform() method of the CensoredWriter. This is a method that the parent class PrintWriter does not have. Transformations of output will utilize String class methods which will replace matched string patterns with the censored text Transformed text will be passed to the parent class print and println methods which will perform the printing. S...

Merge Sort using Multi threading in C++

Introduction: Merge sort implementation in c++ programming but in a way that both left subarray and right sub array start sorting at the same time. You should have to use the multithreading to perform this task. Get your solution now Buy now

2015 Fall Computer Science I Program #3: Mastermind

In the popular game Mastermind, one player creates a secret code of four pegs, each of which can be chosen from one of six colors. (The number of pegs and colors may be different than this in different versions, but your implementation will use these values, but be extendible to other values. Also, a color can be reused, thus there really are six choices for each of the four pegs.) The other player then has to guess the color of each peg, with the order mattering.The player who made the secret code then has to give feed back to the player guessing. This feedback is in the form of white and black pegs. A black peg means that the guesser has chosen the correct color in the correct slot. These are first “calculated” and awarded. Once these are counted, these pegs are ignored. Then the white pegs are awarded. These are for pegs that are the correct color but are in the incorrect slot. There is no “double dipping” of pegs in the response, so the sum total of white and black pegs the guesser...