Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program must be made using 'C' I must create a program that asks the user to input a file (which is called keylist) -

This program must be made using 'C'

I must create a program that asks the user to input a file (which is called keylist) - the key list information - 2 14 74 8 36 4 11 (the numbers above should be in a 'ketlist.txt' file which is the file that the user must input into to program so the program can read the numbers)

Then the user must guess numbers between 1-100 to 'unlock' the treasure chest. the only way for the user to unlock the trasure chest is if the user guess the correct sequence of number (2 14 74 8 36 4 11) however if the user has the correct numbers but in the incorrect ordered the program will tell them '3 of those keys are correct, matey! But are they in the correct order?"

Additionally the user must be prompted that 'You can only use each key once, matey!' if the user inputs '2 2 2 14 8 8 11' the user can only do one input of a number not mutiples. '

This is a guessing game - guess the correct 7 numbers to unlock the chest, the correct answers are in they keylist

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The following is what the program should display. (They keylist is a .txt file and the keyoutput is just the name of the program itself)

KeyList

2 14 74 8 36 4 11

KeyOutput

What is the name of the file?

keylist.txt

-------------------------------

To get to me treasure you'll have to figure out which of me 100 keys are

usedin the 7 locks of me treasure chest.

Which keys will ye use?

2

2

74

8

36

4

11

You can only use each key once, matey! (This is if the user inputs more than 1 of the same key)

Which keys will ye use? (prompted again of what guess they want to make)

14

2

5

70

26

4

1

3 of those keys are correct, matey! But are they in the right order? (The user input 3 correct keys but not in the correct order)

Which keys will ye use? (asked again which keys they want to use)

14

2

74

8

36

4

11

7 of those keys are correct, matey! But are they in the right order? (the user input all of the correct answers but in the incorrect order)

Which keys will ye use?

2

14

74

8

36

4

11

Arr! You've opened me treasure chest and found... (the user guess the correct keys and the order to unlock the chest)

A map! To the rest of me treasure on Treasure Island.

Hahaha!

---------------------------------------------------------------------------------------------------------------------------------------------

for additional information reference the information below

Problem: An Old Pirates Treasure Chest

Your friend has recently come into possession of an old treasure chest. They are convinced there is great treasure inside. They may not even need to go to the Caribbean to get treasure!

The treasure chest is locked with seven locks and your friend has found 100 keys that might fit these locks. Your friend and their crew members will have to try different combinations of keys to try and get the treasure chest open.

Theres one other thing. The treasure chest is haunted! The pirate who previously owned this treasure is still around, reminding other pirates that each lock has a unique key and letting them know if any of their current guesses are correct.

Your program will need to read in a file of the correct combination of keys, numbered 1-100. Then, prompt the user for the seven numbers indicating the seven keys they wish to use. They cannot use the same key twice in one attempt. If they have all the correct keys in the exactly correct order, they can open the chest. If they have some correct keys, regardless of order, let the user know how many keys are correct.

Input File Format

The input file will contain 7 unique integers from 0 to 100.

Program Specification

You must use arrays to solve the problem.

Your program should first prompt the user for the name of the input file. Then, your program should process the input file and copy the correct order of keys into the program. Then you can prompt the user for their first guess. If the user attempts to use a key more than once in a single guess, tell them they can only use each key once. If the user exactly matches the keys and the order, let them open the chest. If the user identifies some of the correct keys, let them know how many keys are correct but tell them they may

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions