This assignment covers file I/O. Must design and code a program that can accomplish four things: copy one file to another (i.e., place the contents of file A into file B), ‘compress’ a file by removing all vowels (a, e, i, o, u, and y) from the file, merge two files, and finally double each line of an input file, saving into an output file. Also make it so the input file's content can be changed from the example given. Please send a test run as well. Please and thank you for your help.
Program Specifications
The program should be menu driven with the top level menu being:
----------------------------------------------------------- Welcome to the File Copier
1) copy file A to file B
2) ‘compress’ file A (remove all vowels from the file), saving into file B
3) ‘double’ file A -- for each character in the input file, repeat it twice in the output file B.
4) ‘merge’ file A and file B saving into file C. (places all of file A in output file C, then adds all of file B after that into file C).
5) quit the program
-----------------------------------------------------------
Appropriate user prompts shall be provided for each choice (e.g.; for selection 2, you must prompt the user for the name of files A and B). Be sure to keep asking them what they want to do until they ask to quit the program. Be sure to check for errors.
For reversing, and compressing a file here is an example:
Input file:
This is a test. The lazy dog ran over the moon.
Able was I ere I saw elba.
I don't know what to type.
Output File (doubled):
TThhiiss iiss aa tteesstt.. TThhee llaazzyy ddoogg rraann oovveerr tthhee mmoooonn..
AAbbllee wwaass II eerree II ssaaww eellbbaa..
II ddoonn''tt kknnooww wwhhaatt ttoo ttyyppee..
Output File (compressed):
Ths s tst. Th lz dg rn vr th mn. bl ws r sw lb. dn't knw wht t tp.
In: Computer Science
In: Computer Science
This is a python 3.0 question, there are either 1 or 2 answers for each sub-question.
Part i) Which of the following statements regarding the opening modes of a file are true?
Select one or more:
a. When you open a file for writing, if the file does not exist, a new file is created.
b. When you open a file for writing, if the file exists, the existing file is overwritten with the new file.
c. When you open a file for writing, if the file does not exist, an error occurs.
d. When you open a file for reading, if the file does not exist, the program will open an empty file.
e. When you open a file for reading, if the file does not exist, an error occurs.
Part ii) What is the data type of the value returned by the read() or readline() methods of a file object, assuming that file object is associated to a pure text file?
Select one or more:
a. int
b. It depends on the data type of the values stored in the file.
c. list
d. str
Part iii) Which of the following methods of a file object reads the entire file into a single string?
Select one or more:
a. readline() if and only if there are no newline characters in the file
b. readlines()
c. read_file_to_str()
d. read()
In: Computer Science
Please re-write and paraphrase all sentences.
Introduction:
It is among the earliest languages
It was developed by Sun Microsystems in 1990s
Applications:
JAVA is used in more then one development environments.
Java has the following outputs:banking applications,desktop applications and mobile operating systems among others.
Efficiency:
Java has is rated high as far as performance is concerned. It is a robust and object oriented programming language and programming environment very efficient in execution and implementation.
Java also has built in libraries that can be implemented at different stages in system development.
Security:
Java has well structured robust security features.
According to O'Reilly and Associates (O'Reilly & Associates, 2001), the language was designed and developed from scratch with security in mind.
Both the language and platform are secure.
Support:
Java developers are more than 9 million all around the globe (Oracle, 2016).
The Oracle corporation is determined to continue providing support to these developers and users.
Oracle's guaranteed supporttranslates to improved security and elimination of system vulnerabilities through updates.
Available Features:
Java provides platform diversity i.e.it can develop mobile phone applications and programs within web browsers.
Offers scripting of many different systems, web apps, phone apps.
It is also dynamic and extensible, that 1s, java code can be converted to other languages.
Suitable for Pine Valley Furniture:
Pine Valley Furniture can usejava to create secure systems, java will help them create scripted programs with design interfaces of their choice.
Python:
Introduction:
It is the most popular language released in 1991.
Applications:
Python is applied t almost every phase of system development.
It is as well used to write short scnpts buld multifaceted object-oriented design and deel application program interface.
Efficiency:
Python is very efficient due to its dynamic nature.
Python works perfectly without the need of a compiler.
It has the best readability and simplicity.
It has an explicit design.
Security:
Python is more secure as analyzed using the present vulnerabilities.
Python was ranked fifth in the present vulnerabilities at 5.45% by Jax Counter ("Which programming language is the most secure? High security vulnerabilities for Java have declined since 2015 JAXenter, 2020).
Java had 11.4% (3-) while rubyhad 4.25% (7).
Support:
It is used by Big tech companies such as Google, Instagram, Quora, and many more.
Python provides constant updates For example python sa legacy language and python 3 s a future language current being enhanced.
Available Features:
Simple syntax, more packages and libraries,easy to read and easy to code.
Very wealthy in terms of web capabilities,educational materials.
Easy function applications creation of pivot table, Boolean indexing plotting multi-indexing and missing files imputation.
Suitable for Pine Valley Furniture:
If Pine Valley Furniture wants to create a very simple and flexible system Python fits in perfectly .
Ruby:
Introduction:
It is among the earliest languages developed It was released in 1993
Applications:
Ruby develops programs with enhanced creativity thinking out of web development box
Ruby has developed several websites Le Twitter GitHub and SlideShare
Efficiency:
Ruby is desgnd tothe clap creative and experimental sites.
Ruby 15 a very flexible programing language and offers quick innovation bence fun to work with.
Security:
Ruby, compared to other popular languages, is more secure with only 4.25% vulnerabilities.
Support:
The fact that Airbnb, Twitter, GitHub, Kickstarter and SlideShare use Ruby language means continued support.
It is a high-end and multipurpose language that ensures fun and flexible programming.
Most programmers and companies are willing to donate to support it as well.
Available Features:
Its strength lies in metaprogramming and the creation of DSL (domain specific languages).
Has automated test scripts for experimentation and creativity.
Suitable for pipe valley Features:
If the Pine Valley Furniture desires to create a web app only, Ruby will be ideal.
Ruby can handle and control billions of traffic and user's data perfectly.
In: Computer Science
Please convert this to work in Oracle SQL:
CREATE TABLE GUEST
(
SSN number(10),
name varchar2(20),
DOB date,
roomnumber number(10)
);
INSERT INTO guest VALUES (1,'Lucy','2019-1-8',301);
INSERT INTO guest VALUES (2,'John','2019-11-18',302);
INSERT INTO guest VALUES (3,'Smith','2019-2-6',303);
INSERT INTO guest VALUES (4,'Tom','2019-2-7',304);
INSERT INTO guest VALUES (5,'Harry','2019-10-9',305);
)
CREATE TABLE INVENTORY
(
itemnumber number(10),
itemneeded number(10),
iteminstock number(10),
dateofpurchase date
);
INSERT INTO INVENTORY VALUES (21,10,60,'2019-1-8');
INSERT INTO INVENTORY VALUES (22,20,70,'2019-1-11');
INSERT INTO INVENTORY VALUES (23,30,75,'2019-2-4');
INSERT INTO INVENTORY VALUES (24,20,55,'2019-3-7');
INSERT INTO INVENTORY VALUES (25,40,65,'2019-5-6');
)
CREATE TABLE VOLUNTEER
(
ssn number(10),
name varchar2(20),
dob date,
skills varchar2(20)
);
INSERT INTO VOLUNTEER VALUES
(31,'Tim','2019-2-7','Beginner');
INSERT INTO VOLUNTEER VALUES
(32,'Lucy','2019-3-11','Advanced');
INSERT INTO VOLUNTEER VALUES
(33,'Jack','2019-1-2','Beginner');
INSERT INTO VOLUNTEER VALUES
(34,'Alice','2019-4-18','Advanced');
INSERT INTO VOLUNTEER VALUES (35,'Bob','2019-3-6','Beginner');
CREATE TABLE SCHEDULE
(
volunteername varchar2(20),
volunteerdaysofwork number(10),
volunteerhours number(10),
guestname varchar2(20),
gueststaydate date
);
INSERT INTO SCHEDULE VALUES
('John',10,5,'Alex','2019-11-5');
INSERT INTO SCHEDULE VALUES
('Lucy',15,4,'Carolin','2019-11-6');
INSERT INTO SCHEDULE VALUES
('Alice',20,3,'Lisa','2019-11-7');
INSERT INTO SCHEDULE VALUES
('Bob',30,4,'Hayden','2019-11-7');
INSERT INTO SCHEDULE VALUES ('TIm',5,2,'Mathew','2019-11-9');
)
CREATE TABLE DONOR
(
donationnumber number(10),
donationamount number(10),
donationdate date,
donorsname varchar2(20)
);
INSERT INTO DONOR VALUES (41,500,'2019-10-3','Alex');
INSERT INTO DONOR VALUES (42,2500,'2019-9-15','Alex');
INSERT INTO DONOR VALUES (43,5200,'2019-7-25','Alex');
INSERT INTO DONOR VALUES (44,700,'2019-11-5','Alex');
INSERT INTO DONOR VALUES (45,2300,'2019-10-6','Alex');
)
In: Computer Science
Using Doubly Linked List, create a java code that does the following Without using LinkedList from the JAVA LIBRARY. and please include methods for each function.
Create a menu that contains the following operations :
1. Add new node to DLL. ( as a METHOD )
2. Delete a node from DLL. ( as a METHOD )
3. Show how many nodes in DLL. ( as a METHOD )
4. Print all data in the DLL. ( as a METHOD )
5. Exit.
Important notes :
1. Write the operations from the pseudocode.
2. The user should insert all data even in the first node.
3. The menu should be repeated each time until the user 5 (Exit).
In: Computer Science
What is a partition and disk formating?
In: Computer Science
how prevalent is identity theft,how does it affect the victims presently and long term and what term and what are some of the issues in prosecuting the offenders?
In: Computer Science
Write a Java program to read in text line by line until a blank line is entered. When this occurs the program returns the total number of words and characters found as shown in the example below.
A program to count the number of words and characters in an input text block.
Enter text line by line; blank line to end.
>> This is the first line of text
>> Followed by the second line of text
>> Ending with the final line of text
>>
Your text contained 21 words and 81 characters.
Your program should be able to reproduce this example (Note that text following the >> prompt is user input to the program).
Instructions
1. Start by writing a method, countLine, to count the number of words and characters in a string. It should have the following signature:
private countObject countLine(String input) {
which returns the total number of words and characters in the input string, where countObject is a simple nested class similar to listNode with two instance variables corresponding to the number of words and characters respectively.
class countObject {
int words;
int chars;
}
Hint: you might consider adding a constructor to initialize this object and getter methods to retrieve each component.
2. Write a main class which implements the user dialog shown in the example. It calls the countLine method to process each line read and adds the counts returned in countObject to the totals. Call this class wordCount.
Hints: You may use that acm.jar is available; the StringTokenizer class can greatly simplify the coding of the countLine method.
Do your coding in Eclipse. Cut and paste wordCount.java into the space provided on the exam.
In: Computer Science
In C, build a connect 4 game with no graphical use interface. Build only the text interface. Use a 2D array as the Data structure. The skeleton of the game is provided for you, Build the game based on the guidelines below. The game does NOT need a mode where you play against the computer. It is simply a game of Connect 4 between player 1 and player 2.
SKELETON:
#include
// Initializing constants
#define NAME_LENGTH 30
#define BOARD_WIDTH 6
#define BOARD_HEIGHT 6
#define GAME 0
#define P_ONE 1
#define P_TWO 2
#define NO 0
#define YES 1
// Declaring variables
char p1[NAME_LENGTH];
char p2[NAME_LENGTH];
int bWidth = BOARD_WIDTH;
int bHeight = BOARD_HEIGHT;
int playCurrent = P_ONE; // Player 1 starts by default
int gameOver = GAME; // GAME = game is running, P_ONE = player one
has won and so on
int p1Quit = NO;
int p2Quit = NO;
//print “Setting up the game”. Ask each player their name.
void Initialization() {
printf("Setting up the
game\n");
printf("Enter your
names\n");
printf("Player
1:\n");
scanf("%s", p1);
printf("Player
2:\n");
scanf("%s", p2);
}
void Teardown() {
printf("Destroying the
game\n");
}
/*accept a letter for which column of the game we are going to drop a disc into. Valid letters are A-G (7 columns). You should designate a letter for “Quit the game”. Input must be returned from this function*/
char AcceptInput() {
char c;
int valid = 0;
do {
printf("Player %d:\n", playCurrent);
printf("Print a character to pick your column (A - G) or Q to
quit\n");
scanf(" %c", &c);
if (c < 'A' || (c > 'G' && c != 'Q')) printf("Invalid
character. Try again\n");
else break;
} while (1);
return c;
}
/*pass the input data to this function. Since we do not have a “world” right now, choosing “A” is the “winning move”, all other letters make the game continue.*/
void UpdateWorld(char c) {
if (c == 'Q') {
if (playCurrent == P_ONE) {
p1Quit = YES;
gameOver = P_TWO;
} else {
p2Quit = YES;
gameOver = P_ONE;
}
}
if (c == 'A') {
gameOver = playCurrent;
}
playCurrent =
playCurrent == P_ONE ? P_TWO : P_ONE;
}
//Print the result calculated in the state of the world
void DisplayWorld() {
if (p1Quit == YES)
printf("Player 1 quit\n");
if (p2Quit == YES)
printf("Player 2 quit\n");
if (gameOver == GAME)
{
printf("Game is currently in process\n");
} else {
printf("Player %d won\n", gameOver);
}
}
/*call initialization, then loop until a flag is set (game over or a player quit), calling accept input, update and display. Outside of the loop, call teardown.*/
int main() {
Initialization();
while (gameOver == GAME
&& p1Quit == NO && p2Quit == NO) {
char c;
c = AcceptInput();
UpdateWorld(c);
DisplayWorld();
}
Teardown();
return 0;
}
Connect Four is a game that alternates player 1 and player 2. You should keep track of whose turn it is next. Here are the guidelines for building the game.
In: Computer Science
The main purpose of this lab is to reinforce the lectures on code style and documentation.
Make as many improvements to the code style as you can including white space, variable names, etc. (NOTE: do this manually – no automated formatting tools allowed). Comment the file completely.
#include <iostream>
#include <cmath>using namespace std;
const int A_CONSTANT = 3;
void functionA(int a[], int aNumber);
void functionB(int a[], int anotherNumber);
void functionC(const int anArray[], int aNumber);
void functionD(int& sum);
int functionE(double number); void functionF(int n);
int main( ){
int production[A_CONSTANT];
cout << "This program displays a graph showing\n" << "production for each factory in the company.\n";
functionA(production, A_CONSTANT);
functionB(production, A_CONSTANT);
functionC(production, A_CONSTANT);
return 0;}
void functionA(int a[], int aNumber){
for (int someNumber = 1;someNumber <= aNumber; someNumber++)
{ cout << endl << "Enter production data for plant number " << someNumber << endl; functionD(a[someNumber - 1]);}}
void functionD(int& sum){
cout << "Enter number of units produced by each department.\n" << "Append a negative number to the end of the list.\n";
sum = 0; int next;
cin >> next;
while (next >= 0) {
sum = sum + next;
cin >> next; }
cout << "Total = " << sum << endl;
}
void functionB(int a[], int anotherNumber){
for (int index = 0; index < anotherNumber; index++)
a[index] = functionE(a[index]/1000.0);
}
int functionE(double number) {
return static_cast<int>(floor(number + 0.5));
}
void functionC(const int anArray[], int aNumber){
cout << "\nUnits produced in thousands of units:\n";
for (int someNumber = 1; someNumber <= aNumber; someNumber++) {
cout << "Factory #" << someNumber << " ";
functionF(anArray[someNumber - 1]);
cout << endl;
}
}
void functionF(int n) {
for (int count = 1; count <= n; count++) cout << "*";
}
In: Computer Science
Implement a superclass Person. Make two classes, Student and Instructor, that inherit from Person. A person has a name and a year of birth. A student has a major, and an instructor has a salary. Write the class declarations, the constructors, and the methods toString for all classes. Supply a test program that tests these classes and methods.
In: Computer Science
Visual Basic Question :
Sum = 1 + 1/2 + 1/3 + 1/4 + .......
A project which allows the user to enter a number in the Textbox1 and which indicates the number of terms on the Label
e.g. I enter 10 (sum) in the Textbox1 and Label1 indicates 12367 (terms)
I have tried a few days but it does not work... thanks for your help!
dim i, t as integer
for i = 1 to t-1
textbox1 = textbox1 + 1/i
next
Label1 = t
In: Computer Science
Write a programme to read and print your phone number,
your initials and your average.
note:c++
In: Computer Science
Question 1
i) A binary system uses 8-bits to represent an analog value ranging from 120 ounces to 700 ounces, determine the resolution of the system and interprete your result.
ii) Determine the number of bits that would be needed for the above resolution to improve to better than 0.01 ounces per increment. Interpret your results.
iii) Use the binary coded decimal (BCD) representation of integers to represent each of the following integers.
2194
4576
7865
3947
3782
In: Computer Science