1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
katrin [286]
3 years ago
12

p25: File Write and Read1) User enters a file name (such as "myMovies.txt").2) User enters the titles of 4 of their favorite mov

eis (use a loop!).3) Program Writes the 4 titles to a file, one per line, then closes the file (use a loop!).4) Program Reads the 4 titles from "myMovies.txt" stores them in a list and shows the list5) The program writes the titles in reverse order into a file "reverseOrder.txt"Sample Run:Please enter a file name: myMovies.txtPlease enter a movie title #1: movie1Please enter a movie title #2: movie2Please enter a movie title #3: movie3Please enter a movie title #4: movie4Writing the 4 movie titles to file 'myMovies.txt'Reading the 4 movie titles from file into a list: [movie1, movie2, movie3, movie4]Writing the 4 movie titles in revers to 'reverseOrder.txt'Note: Do not use reverse() , reversed()Content of myMovies.txt:movie1movie2movie3movie4Content of reverseOrder.txtmovie4movie3movie2movie1
Computers and Technology
1 answer:
SCORPION-xisa [38]3 years ago
6 0

Answer:

<em>The program goes as follows  </em>

<em>Comments are used to explain difficult lines</em>

#include<iostream>

#include<fstream>

#include<sstream>

#include<string>

using namespace std;

int main()

{

//Declare String to accept file name

string nm;

//Prompt user for file name

cout<<"Enter File Name: ";

getline(cin,nm);

//Create File

ofstream Myfile(nm.c_str());

//Prompt user for 4 names of movies

string movie;

for(int i = 1;i<5;i++)

{

 cout<<"Please enter a movie title #"<<i<<": ";

 cin>>movie;

 //Write to file, the names of each movies

 Myfile<<movie<<endl;

}

Myfile.close(); // Close file

//Create an Array for four elements

string myArr[4];

//Prepare to read from file to array

ifstream file(nm.c_str());

//Open File

if(file.is_open())

{

 for(int i =0;i<4;i++)

 {

  //Read each line of the file to array (line by line)

  file>>myArr[i];

 }

}

file.close(); // Close file

//Create a reverseOrder.txt file

nm = "reverseOrder.txt";

//Prepare to read into file

ofstream Myfile2(nm.c_str());

for(int j = 3;j>=0;j--)

{

 //Read each line of the file to reverseOrder.txt (line by line)

 Myfile2<<myArr[j]<<endl;

}

Myfile2.close(); //Close File

return 0;

}

See attached for .cpp program file

Download cpp
You might be interested in
One of the earlier applications of crypto-graphic hash functions was the storage of passwords to authenticate usersin computer s
vagabundo [1.1K]

Answer: provided in the explanation part.

Explanation:

This is actually quite long but nevertheless i will make it as basic as possible.

Question (a)  

Attack A:

One way property of hash means that we can't find the input string if given the hash value. The calculation of hash from input string is possible but it is not possible to calculate the input string when given the hash. If the hash function is properly created to have one-way property then there is no way of finding the exact input string. So this attack won't work as the one-way property of hash function can't be broken if the hash function is properly created.

Attack B:

Suppose h() is the hash function. And h(x) = m where x is the string and m is the hash. Then trying to find another string y such that h(y) = m is called finding out the second pre-image of the hash.

Although we can't know the exact initial string for sure, we can by using brute force method find out a second preimage.

This attack will take a very long time. It has the time complexity of 2n. It requires the attacker to have an idea about the kind of passwords that might be used and then brute force all of them to find the string that has the same hash. Each try will have a chance of 1/2n to succeed.

Rainbow attack using rainbow table is often used for such brute-force attack. This comprises a rainbow table which contains passwords and their pre-hashed values.

Therefore, it is not possible to determine the second preimages of h so easily.

Attack C:

Collisions refer to finding out m and m' without knowing any of them. Finding out collisions is easier than finding preimages. This is because after finding out 2n pairs of input/output. The probability of two of them having the same output or hash becomes very high. The disadvantage is that we can't decide which user's hash to break. However, if I do not care about a particular user but want to get as many passwords as possible, then this method is the most feasible.

It has the time complexity of 2n/2.

Hence, this is the attack which has the most success rate in this scenario.

Question (b)

The brute force way of finding out the password usually involves using a rainbow attack. It comprises a rainbow table with millions of passwords and their hashes already computed. By matching that table against the database, the password can be recovered.

Therefore it is often preferred to salt the password. It means we add some random text to the password before calculating the hash.

The salts are usually long strings. Although users usually do not select long passwords, so a rainbow table with hashes of smaller passwords is feasible. But once salt is used, the rainbow table must accommodate for the salt also. This makes it difficult computationally. Although password might be found in the rainbow table. The salt can be anything and thus, make brute-force a LOT more difficult computationally.

Therefore salt is preferred to be added to passwords before computing their hash value.

Question (c)

A hash output length of 80 means there can be exactly 280 different hash values. This means there is at least one collision if 280+1 random strings are hashed because 280 values are used to accommodate all the possible strings. It is not hard with today's computation power to do match against more than this many strings. And doing so increases the probability of exposing a probable password of a user.

Hence, 80 is not a very secure value for the hash length.

cheers i hope this helps!!!!

6 0
3 years ago
What would be the best course of action for the scenario below? A user has a large amount of data that she or he needs to store.
horrorfan [7]
Bluetooth connection data on nonvolatile storage media such as a USB
7 0
3 years ago
I am trying to test out the software Classroom relay and I am just ask if there is any way kids can stop Classroom relay form se
Ratling [72]

Answer:

just don't share your screen in the class or if your a teacher just call them out

Explanation:

8 0
2 years ago
Read 2 more answers
Your laptop normally connects to your home wireless network automatically, but recently you have to connect to the network manua
finlep [7]
Your software is not remembering your password or SSID , maybe your router also has a forget all setting
8 0
3 years ago
Portrait and Landscape are
kramer

Answer:

Page orientation

Explanation:

Required

What does portrait and landscape represent?

For better understanding, I'll narrow down the question to Microsoft Office Word. The explanation can be applied to other concepts.

Analysing the option one after the other.

Page layout: This is a term that describes the graphical representation of each document page, visually.

Page Size: This is a term that represents the length and width of the page. Common page sizes are LETTER, A4, A3, and so on.

The above (2) do not in any way represent what portrait and landscape represent.

Page orientation: This is a way the document is represented and it's a direct synonym for landscape and portrait.

Since (1) & (2) do not represented the given term, the last option is incorrect.

Hence,

Page orientation correctly answers the question

8 0
3 years ago
Read 2 more answers
Other questions:
  • W jakim celu powstawały pieśni żołnierskie i partyzanckie?
    10·1 answer
  • What tool is provided in Windows to facilitate sharing data objects between applications and computers?
    8·1 answer
  • Jim wants to buy a car, but he’ll probably only need it for a couple of years. He has a short commute to work, so he won’t be pu
    10·1 answer
  • When Gina was 10, she swam in the ocean for the first time. She remembers the feeling of kicking her feet, slicing her arms thro
    12·1 answer
  • 3.3 Code Practice: Question 1
    15·1 answer
  • I live in Alabama and I’m ab to leave to go on a 3 week trip to France and I’m wondering how I can get LTE for my IPhone 6s Plus
    15·2 answers
  • DERECTIONS: Identify all the computer software that you need for the following entrepreneurial activities. Refer your answer fro
    5·1 answer
  • Most case fans have standard _______________ connectors that are easy to plug in but can be forced to be connected the wrong way
    14·1 answer
  • What is a phone made out of dna
    15·1 answer
  • a central issue in the microsoft antitrust lawsuit involved microsoft's integration of its internet browser into its windows ope
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!