Gå til innhold

Trenger hjelp til å lage C ++ program ?


Anbefalte innlegg

Hei ! Er det noen her som kunne tenke seg å hjelpe meg med å lage et C++ program ? Takk på forhånd. Her er beskrivelser :

 

 

You are to write a program to manage an engineering journal. An engineering journal is a record of a person’s activities and thoughts while they work on a project. Entries are added to a journal but they can not be deleted. An employer can read a worker’s engineering journal and see how they are going.

The format of this journal will be simple. Each entry will have a one line title and a one paragraph text entry (an example text file is provided).

Encoding and Decoding

 

Entries in the journal are private, so the journal is encoded and protected using a pin.

When the program is executed it will ask for a 4¬digit pin. The pin is to be stored in the

program as an integer array. You are to use this pin to encode and decode the journal

entries (but NOT the titles – they are to remain in plain text).

When saving the file, each character in the journal paragraph is to have the integer value

of the next digit in the pin added to the character to encode. When decoding the file, the

next digit in the pin is subtracted from the character.

 

To encode the entry when saving to file:

The first digit will be added to the first character of the text.

The second digit will be added to the second character of the text.

The third digit will be added to the third character of the text.

The fourth digit will be added to the fourth character of the text.

… and so the cycle repeats.

The first digit will be added to the fifth character of the text.

E.g. if using the pin 1234, the entry abcdefgwould be encoded bdfhfhj

Program Features

The program is to provide the following facilities using a menu:

• Display a list of the titles in the journal.

• Display the contents of a selected entry (by number)

• Add an entry to the journal

• Quit

 

Error Handling

You are to handle the errors if a file fails to open for reading or writing (with appropriate

error messages). You should also display an error and re¬prompt the user if they do not

enter 4 characters for the pin, or if the pin contains a non¬numeric character.

Note that you do not need to keep the list of titles or journal entries in memory. You can read them from the file each time entries or titles are displayed. The journal file provided for this assignment is the required format you must use.

All files should be submitted by uploading them through LearnJCU. If you do your planning by hand, you should clearly label this paper and hand it in to your lecturer.

Planning (one document – Word doc or PDF):

 

• IPO charts for each function with the algorithm in either pseudocode or flowchart

 

If you are doing a flowchart, it may be hand¬drawn, but it must be neat. See your textbook examples for the desired format. This part of the assignment can be shown to your tutor during the practical in week 10, when they will make comments or suggestions. You can show them again in week 11 to confirm.

• A completed desk¬check table

 

This only needs to be done for one run through the program – using logical values. Name this file: LastnameFirstnameA2.doc or .docx or .pdf

Program (one code files):

Hand in a single .cpp file (no projects or other files). You may like to show your tutor your code during the practical in week 11 in order to get appropriate feedback. Name this file: LastnameFirstnameA2.cpp

Note that your code must work with the journal file provided, so do not upload a new journal text file.

Sample Output:

Note that the following runs of the program all use the same journal.txt file above.

Engineering Journal – Your Name

Enter your 4 digit pin number: 1234

Select Option ([L]ist Titles, [D]isplay Item, [A]dd Item, [Q]uit): l

 

1. Program Design

 

2. Flow Charts

 

3. Encoding and Decoding

 

Select Option ([L]ist Titles, [D]isplay Item, [A]dd Item, [Q]uit): d

Please enter item number: 1

Must read the program description thoroughly. I don't want to miss out on easy marks like I did in the previous assignment.

Select Option ([L]ist Titles, [D]isplay Item, [A]dd Item, [Q]uit): a

Enter Title: File I/O

Enter new item: Must remember to close the file every time it is opened. I will also need error checking in case the file fails to open.

Save new item [y/n]: Y

Journal entry saved.

Select Option ([L]ist Titles, [D]isplay Item, [A]dd Item, [Q]uit): l

 

1. Program Design

 

2. Flow Charts

 

3. Encoding and Decoding

 

4. File I/O Select Option ([L]ist Titles, [D]isplay Item, [A]dd Item, [Q]uit): d Please enter item number: 4 Must remember to close the file every time it is opened. I will also need error

 

checking in case the file fails to open. Select Option ([L]ist Titles, [D]isplay Item, [A]dd Item, [Q]uit): Q

Note that the pin “1234” was the right pin for decoding the entry thus the entry was displayed properly.

Another run… (same file)

Engineering Journal – Your Name Enter your 4 digit pin number: qwerty Invalid pin. Enter your 4 digit pin number: 43x1 Invalid pin. Enter your 4 digit pin number: 432 Invalid pin. Enter your 4 digit pin number: 4321 Select Option ([L]ist Titles, [D]isplay Item, [A]dd Item, [Q]uit): i Invalid option. Select Option ([L]ist Titles, [D]isplay Item, [A]dd Item, [Q]uit): l

 

1. Program Design

 

2. Flow Charts

 

3. Encoding and Decoding

 

4. File I/O Select Option ([L]ist Titles, [D]isplay Item, [A]dd Item, [Q]uit): d Please enter item number: 4 Jttw↔qfpblcho▼ur↔bmrpd!wed!ifkf#bufuv▼uljd!lq▼jv↔nqhkde1↔H!zfkm#^ktr↔mfha

 

▼fuons#`gffhhoj↔ho#``th↔sih↔ejob▼gdfkt#qn!rmdo1 Select Option ([L]ist Titles, [D]isplay Item, [A]dd Item, [Q]uit): q

Note that although the pin format was valid and was accepted, it was the wrong pin for decoding these entries. Note also that there is no display or pause after quitting.

 

 

journal.txt

( Program Design

 

Nwvx!thee"wlf"svpiuen"giteumqvlso"wlptryhjo}/"L$eqq+u"zeov#xp"pmtu#svv#so"het{#qbtnw!nlof"L$ekg$jp#xig#tsgympwv$buvmhppiov1

 

Flow Charts

 

Xkop!phie"d$tgsescwi!hosx"flbtw$)qu$quhyeq#gpfh-!hrv!odmo"dre"iss"hedj#moflzjfxem"iyoewmpp1$Nclr!ylpm"qiff#xp"ei!ulqqnh$bpg$xkop!wvi!hxrdvlso"femnv$gqu$fcfl!hxrdvlsoco$cnrgl"zmujlr!vki!rushtdq!k1i/"omtv/$ekvtmc|$fpwvz"dre"dhe"hrut|2!Uksvng$hgw$qkq$bnvs!dh$b"viqcueug#jvpfxjqqC

 

Encoding and Decoding

 

J"wljpn$J"zmmn#mokwmbno}!yumug#xig#tsqjvbo#{jvksvv#ioerhjpj$bpg$egfsekqk/"Rrdg#xig#tsqjvbo#mt"zssmlrh"L$xkop!cgh!vkitg#et"iyoewmppv$mcwis"dre"femn#xigp$kwvx!dhjpth$fcfl!thee"dre"zvjvh2

 

File IO

 

Nwvx!thqfoeis"ws!eostg#xig#jjnh$fxhvz"wmng#mu"lw!qsiogg2!K#{jno$bnvs!phie"hvsqu$djhglkqk!kq$dcvi!vki!hlpf"iejnv$uq#sqgq2

 

IPO Chart

 

Icyi!lxwu"fsnroiugg$n{#MQQ#gicux!cqh!hosx"flbtw2!Ylpm"qsx"gitm#gigfo!vkin"ws!odof"vysg#qz"dphqumujp$ju#gptuidv#ffhrvf"L$cgjmo"ws!kptmgpiov#xig#gpfh2 )

Lenke til kommentar
Videoannonse
Annonse

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
  • Hvem er aktive   0 medlemmer

    • Ingen innloggede medlemmer aktive
×
×
  • Opprett ny...