hey.. im new in c++ and im doing an engineering journal as my assignment.. i dun know how to do this..

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.

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 abcdefg would be encoded bdfhfhj
Hint: strings are arrays of characters and numbers can be added to strings, e.g. myString[0] + 1


pls help me=(

Sorry, we will not just do your assignment for you. We also cannot teach you all of c++ - you're going to have to give it an attempt and we can help when you run into problems.

//Engineering Journal-CP1200

#include <iostream>
#include <string>
#include <fstream>

using namespace std;

void listTitles();
void displayItem(int);
int main(){
    
    int p[4] = {1,2,3,4};
    string name = "Kimberly Pelayo ";
    int i;
    char ans = ' ';
    int num = 0;
    string newItem;
    string title;
    int n;
    
    cout << "Engineering Journal - " << name << endl << endl;
    cout << "Enter your four digit pin: ";
    cin >> p[4];
    
    do{
     cout << endl;
     cout << "Select Option ([L]ist Titles, [D]isplay Item, [A]dd Item, [Q]uit): ";
     cin >> ans;
     cout << endl;
     
     switch (ans){
            case 'l':
                 listTitles();
                 break;
            case 'd':
                 displayItem(n);
                 break;
            case 'a':{
                 ofstream fout("journal.txt");
                 fout.open("journal.txt");
                 cout << "Enter title: ";
                 cin >> title;
                 cout << "Enter new item: ";
                 getline(cin, newItem);
                 fout << newItem;
                 fout.close();
                 }
            case 'q':
                 break;
            default:
                break;                
                   
     }
      
}while(ans != 'q');
    
}
//***function definitions***
void listTitles(){
    string titles;
    ifstream fin("journal.txt");
    getline(fin, titles, '\n');
    cout << titles << endl;
    getline(fin, titles, '\n');
    cout << titles << endl;
    getline(fin, titles, '\n');
    cout << titles << endl;
    fin.close();
}
void displayItem(int num){
   string journal;
   cout << "Please enter number: ";
   cin >> num;
       if(num == 1){
   ifstream fin("journal.txt");
   getline(fin, journal, '\n');
   cout << journal << endl;
   }
}

i am not finished with it yet.. im so lost now..

^that's my code so far.. =(

Please ask specific questions. Also, provide sample input, expected output, and the current (incorrect output).

may i ask how to do the 6 digit code in c++

commented: Yes but put that in a new discussion and show your work so far. +17
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.