Program:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream in("hw6-Spring2017.txt");
if(!in)
{
cout << "Cannot open input file.\n";
return 1;
}
char str[255][255];
int i=0;
while(in)
{
in.getline(str[i++], 255); // delim defaults to '\n'
}
for(int j=65; j<=90; j++)
{
bool status = false;
int pos = 0;
for(int k=0; k<i; k++)
{
for(int l=0; str[k][l] != '\0'; l++)
{
pos++;
int temp = str[k][l];
if(temp == j)
{
status = true;
break;
}
}
if(status == true)
break;
}
char ch = j;
cout<<"Character: "<<ch;
if(status)
cout<<" Position: "<<pos<<endl;
else
cout<<" Position: 0"<<endl;
}
for(int j=48; j<=57; j++)
{
bool status = false;
int pos = 0;
for(int k=0; k<i; k++)
{
for(int l=0; str[k][l] != '\0'; l++)
{
pos++;
int temp = str[k][l];
if(temp == j)
{
status = true;
break;
}
}
if(status == true)
break;
}
char ch = j;
cout<<"Character: "<<ch;
if(status)
cout<<" Position: "<<pos<<endl;
else
cout<<" Position: 0"<<endl;
}
for(int j=97; j<=122; j++)
{
bool status = false;
int pos = 0;
for(int k=0; k<i; k++)
{
for(int l=0; str[k][l] != '\0'; l++)
{
pos++;
int temp = str[k][l];
if(temp == j)
{
status = true;
break;
}
}
if(status == true)
break;
}
char ch = j;
cout<<"Character: "<<ch;
if(status)
cout<<" Position: "<<pos<<endl;
else
cout<<" Position: 0"<<endl;
}
in.close();
return 0;
}
***Please note: Blank space and other special characters are skipped.
Sample input file:
Sabrina Sidney (1757–1843) was a British foundling girl taken in
when she was 12 by the author Thomas Day,
who wanted to mould her into his perfect wife. As an adult she
worked with the schoolmaster Charles Burney,
managing his schools. In 1769 Day took Sabrina to France to begin
methods of education inspired by Rousseau's Emile,
or On Education. When she reached her teenage years, Day's friend
Richard Lovell Edgeworth persuaded him that his
ideal-wife experiment had failed. In 1783 Sabrina was told the
truth about Day's experiment and confronted him
in a series of letters. In 1804, Anna Seward published a book about
Sabrina's upbringing. In his 1820 memoirs,
Edgeworth said that Sabrina and Day made a good match and that she
loved him. Sabrina countered that Day had
made her miserable, and that she had effectively been a slave. The
story of Sabrina's life has been told in Wendy
Moore's 2013 book How to Create the Perfect Wife and dramatised in
the 2015 BBC Radio 4 play The Imperfect Education of Sabrina
Sidney.
Sample output:
Character: A Position: 157
Character: B Position: 36
Character: C Position: 202
Character: D Position: 105
Character: E Position: 328
Character: F Position: 268
Character: G Position: 0
Character: H Position: 912
Character: I Position: 240
Character: J Position: 0
Character: K Position: 0
Character: L Position: 409
Character: M Position: 894
Character: N Position: 0
Character: O Position: 338
Character: P Position: 930
Character: Q Position: 0
Character: R Position: 317
Character: S Position: 1
Character: T Position: 98
Character: U Position: 0
Character: V Position: 0
Character: W Position: 352
Character: X Position: 0
Character: Y Position: 0
Character: Z Position: 0
Character: 0 Position: 589
Character: 1 Position: 17
Character: 2 Position: 82
Character: 3 Position: 27
Character: 4 Position: 26
Character: 5 Position: 19
Character: 6 Position: 245
Character: 7 Position: 18
Character: 8 Position: 25
Character: 9 Position: 246
Character: a Position: 2
Character: b Position: 3
Character: c Position: 148
Character: d Position: 11
Character: e Position: 13
Character: f Position: 44
Character: g Position: 52
Character: h Position: 42
Character: i Position: 5
Character: j Position: 0
Character: k Position: 61
Character: l Position: 49
Character: m Position: 101
Character: n Position: 6
Character: o Position: 45
Character: p Position: 143
Character: q Position: 0
Character: r Position: 4
Character: s Position: 32
Character: t Position: 39
Character: u Position: 46
Character: v Position: 411
Character: w Position: 30
Character: x Position: 461
Character: y Position: 14
Character: z Position: 0
Scareenshot:
Write a new program (hw6-pr1) meeting at least the following minimum requirements: Opens the text version...
1) Copy bother10.sh from /home/ghoffman/course_files/it244_files to your hw6 directory. Run this program in the background redirecting output to /dev/null. Be sure you copy and run bother10.sh, NOT bother.sh. 2) Run a command that shows the job number of the process running bother10.sh. 3) Run a command that shows the process ID of the process running bother10.sh. 4) Copy the script make_foo.sh from ~ghoffman/course_files/it244_files to your current directory. Run this script. Using touch, create the file foo.txt. Perform a long listing...
Phone Number Problem (Use Object-Oriented Programming Style. Otherwise there will be no credit) Write a C++ program that can convert any 7-digit telephone number into corresponding words where the equivalence of each digit and its corresponding characters is defined in the telephone keypad, which is shown in the following table: ABC 4 1 JKL MNO 8 TUV WXYZ In the keypad, there is no equivalence for digit 1 and 0, but in reality, the phone number might contain those two...
Write an LC-3 program (starting at memory location 0x3000) to take a string as input and then output information about this string. The end of the string will be denoted with the "#" character. Once the "#" has been found, output the following in order: 1) The letter “u” followed by the number of uppercase letters in the string (A-Z) 2) The letter “l” followed by the number of lowercase letters in the string (a-z) 3) The letter “n” followed...
Write a C program which will display the contents of a file in base-16 (hexadecimal) and in ASCII. Complete the following tasks: Obtain the name of the input file from the command line. If the command-line is “./hexdump xxx.bin” then argv[1] will contain “xxx.bin”. Open the file for binary input Print the entire file, 16-bytes per line. Each line should begin with an 8-digit hexadecimal offset into the file. This is the count of the bytes that you have already...
Write a Java program called Flying.java that, firstly, prompts (asks) the user to enter an input file name. This is the name of a text file that can contain any number of records. A record in this file is a single line of text in the following format: Num of passengers^range^name^manufacturer^model where: Num of passengers is the total number of people in the plane. This represents an integer number, but remember that it is still part of the String so...
Use c-strings for the following project: Write a C++ program that declares an array containing up to a maximum of 20 sentences, each sentence of maximum 81 characters long, using c-strings. Continue reading sentences from the user and store them in the array of sentences, until the user enters a NULL string for the sentence or 20 sentences have been entered. Then, one by one, display each sentence entered by the user and present the following menu of operations on...
Need a quick solution to this in Java! OPTION 2: RADIX SORT TESTING Write a version of Radix Sort to sort an ArrayList or array of ints / Integers that you will place in a file. The integers should all be four digits long. Run the algorithm on at least 3 different files, of different sizes (i.e., each file should have a different number of integers) and have it print the results. The minimum file size should be 20 integers....
I need eclipse code for : Write a program that analyzes text written in the console by counting the number of times each of the 26 letters in the alphabet occurs. Uppercase and lowercase letters should be counted together (for example, both ‘A’ and ‘a’ should count as an A). Any characters that are not letters should be ignored. You must prompt the user to enter the text to be analyzed. Then, for any letter that appeared at least once...
In either Java or Python 3, write a program that simulates a deterministic FSM. It will read from two input files. The first is a file describing an FSM The first line contains the alphabet as a series of characters separated by a single space - The second line contains the number of states as an integer k 2 1; states will be numbered 0,1,..., k -1. The start state is always state O The third line contains a series...
In either Java or Python 3, write a program that simulates a deterministic FSM. It will read from two input files. The first is a file describing an FSM The first line contains the alphabet as a series of characters separated by a single space - The second line contains the number of states as an integer k 2 1; states will be numbered 0,1,..., k -1. The start state is always state O The third line contains a series...