Assignment Instructions

  1. Edit, compile, and run the following program on the UH UNIX shell:
    1. Sort this file (assignment26.txt) of English and Japanese words.
    2. Here is starter code for your assignment: LastnameFirstname26.cpp. Download it to your computer and change the name of the file and name of the class to your last name and first name. Change the comments as appropriate.
    3. In sorting them, disregard case - a capital letter is considered the same as the corresponding lowercase letter. Also, disregard anything enclosed in brackets at the beginning of a line, anything enclosed in parentheses at the beginning of a line, and disregard spaces at the beginning of a line. The lines in the output should look identical to the lines in the input, but they will be sorted in the English word order. The lines in the output should form two columns, with the first letter of each word lining up with all the other words. See the example output below for details.
    4. Use commandline input to input the filename. For example, the UNIX command is: ./program assignment26.txt
    5. In your program, argv[1] will contain the filename. Use the ifstream class for file input.
    6. Read one line at a time from the input file.
    7. Break the line into three parts: the original English part,the original Japanese part, and the sort field.
    8. The English and Japanese words are divided by a tab ("\t"). To split the English and Japanese parts, find the character position of the tab. Then take the substring of the first part of each line for the English part, and the substring of the second part of each line for the Japanese part. Store these in two separate variables.
    9. Store the sort field in a third variable. The sort field is equivalent to the English part with a few changes. Change all of the capitalized English characters to lowercase letters. Remove any characters enclosed in brackets in front of any words. Next, remove any characters enclosed in parentheses in front of any words. Remove the space in front of any words.
    10. Define a class Entry in which each object has three strings in it, the English, the Japanese, and the sort field (three data members).
      You need a default constructor (a constructor with no parameters) for Entry.
      You need three set functions and three get functions for the three data members (strings english, japanese, and sortfield).
      Overload the operator< (less than operator), because the less than operator will be used to sort these objects by the sort field. In other words, we will need the less than operator to compare the sort field of two Entry objects with one another. For example, if we have two entry objects, such as:
      Entry entry1, entry2;
      If entry1 < entry2 is true, then entry1 should precede entry2 for sorting these objects.
      The first line of the operator<() function definition should be:
      bool operator< (const Entry e) const{
      The code inside the operator<() function definition should be: If the sortfield of this object is less than the sortfield of the parameter, then return true. Otherwise, return false.
    11. Make a vector of Entry objects. Read the data from the file one line at a time, break the line into three parts as described above, and store the data for each line in an Entry object. Store each Entry object in the vector.
    12. Sort the vector of Entry objects. Use the sort() funtion. See the vector.cpp example program.
    13. Display the English and Japanese parts of the sorted Entry objects.
    14. To display Entry objects, you will have to write a friend function to overload operator<< (so you can use cout to output Entry objects), or you will need to use the get() functions to access the English and Japanese words.
    15. Use the field width and left justification to display the English and Japanese words as displayed below in the example output.
    16. Email your makefile and C program to the instructor, or show it to the instructor in class.
  2. For the submission guidelines and the grading guidelines, see the syllabus.

Example I/O

./a.out  assignment26.txt

A.M.                                            gozen 
about (time)                                    -koro -goro
about ~ [Not used for time.]                    -kurai -gurai 
absent                                          (o)yasumi 
(be) absent (from ~)                            (-o) yasumimasu 
address                                         juusho 
after (not time)                                (-no) ato de 
after (time)                                    -sugi 
again                                           mata 
airplane                                        hikooki 
all right                                       daijoobu 
already                                         moo (+aff.) 
always                                          itsumo 
am                                              desu 
America                                         amerika 
amuse [not used for sports & music]             asobimasu 
(Noun1) and (Noun2), etc.                       (N1) ya (N2) 
and [only at beginning of sentence]             soshite 
and [used between two nouns]                    to 
And then                                        sorekara 
(not) anything                                  nanimo+Neg.
(not to) anywhere                               dokoemo+Neg. 
April                                           shigatsu 
are                                             desu 
art                                             bijutsu 
at (location)  [with existence verb]            ni 
at (place) [with action verb]                   de 
[with action verb]at (specific time)            (specific time) ni 
[with existence verb](not) at all               zenzen+Neg. 
August                                          hachigatsu 
aunt                                            obasan 
autumn                                          aki 
bad                                             warui 
bag                                             baggu 
ball point pen                                  boorupen 
balloon                                         fuusen 
baseball                                        yakyuu 
basketball                                      basuketto(booru) 
bathroom                                        (o)toire, (o)tearai 
beach                                           umi 
beard                                           hige 
beautiful                                       utsukushii 
because                                         (reason) kara,  (result) 
bed                                             beddo 
before                                          mae 
before (not time)                               (-no) mae ni 
before (time)                                   -mae -
begin                                           hajimemasu 
Besides [at beginning of a sentence]            soreni 
bicycle                                         jitensha 
big                                             ookii 
bird                                            tori 
birthday                                        (o)tanjoobi 
(is) black                                      kuroi 
black                                           kuro 
(is) blue                                       aoi 
blue                                            ao 
boat                                            fune 
body                                            karada 
book                                            hon 
bookstore                                       honya 
boring                                          tsumaranai 
born in (month)                                 -gatsu umare -
bow                                             rei 
bowlful                                         -pai -
box lunch                                       bentoo 
boy                                             otoko no ko 
bread                                           pan 
(a) break                                       yasumijikan 
breakfast                                       asagohan 
(is) brown                                      chairoi 
brown                                           chairo 
building                                        tatemono 
bus                                             basu 
busy                                            isogashii 
But [at beginning of a sentence.]               demo 
but [less formal than demo]                     (sentence 1) ga, (sentence 2)  
buy                                             kaimasu 
by (tool)                                       (tool) de 
by (transportation facility)                    (transportation) de 
cafeteria                                       kafeteria 
camera                                          kamera 
camp                                            kyanpu 
can do well                                     tokui 
can hear                                        kikoemasu 
can see                                         miemasu 
candy                                           ame, kyandii 
cannot hear                                     kikoemasen 
cannot see                                      miemasen 
cap                                             booshi 
car                                             kuruma, jidoosha 
(playing) cards                                 toranpu 
cat                                             neko 
cent(s)                                         -sento -
chair                                           isu 
cheap                                           yasui 
child                                           kodomo 
China                                           chuugoku 
Chinese language                                chuugokugo 
chocolate                                       chokoreeto 
chopsticks                                      (o) hashi (
class                                           jugyoo, kurasu 
classroom                                       kyooshitsu 
clean                                           kirei 
clock                                           tokei 
(to) close                                      shimemasu 
close, near                                     chikai 
(Please) close.                                 shimete kudasai 
cockroach                                       gokiburi 
coffee                                          koohii 
coffee shop                                     kissaten 
cola                                            koora 
(a) cold                                        kaze 
(is) cold                                       samui 
(is) cold (to the touch)                        tsumetai 
college                                         daigaku 
college student                                 daigakusei 
color                                           iro 
come                                            kimasu 
company                                         kaisha 
company employee                                kaishain 
computer                                        konpyuutaa 
concert                                         konsaato 
Congratulations.                                omedetoo gozaimasu. 
cool [temperature]                              suzushii 
cousin                                          itoko 
cup                                             koppu 
cupful                                          -pai -
cute                                            kawaii 
dance                                           dansu 

Click to validate the HTML code

Click to validate the CSS code