SlideShare a Scribd company logo
i need help fixing my program so that the user can input both uper and lower case letters
Write a new C++ program named Vigerene.
use the rules of this website Code.org to return the message
Code.org (Links to an external site.)
Write the C++ program, Vigerene, which will prompt the user for a string message and a string
secret code. The code must be shorter than the message. Then write a function which takes the
message and code as parameters, and converts the two strings into a encrypted code using the
rules on the code.org website. Return the encrypted message and print it in the Main class.
Now write a new function which takes in an encrypted message and a secret code as two
parameters and decrypts the the message and returns it to Main for printing.
Here is sample output:
Enter your messge: my name is rick
Enter your secret code: helloworld
TBKYOHSQTVGVTNY
Enter your encrypted message
TBKYOHSQTVGVTNY
MY NAME IS RICK
code:
#include <iostream>
#include <string>
using namespace std;
string encrypt(string message, string code) {
string encrypted = "";
int j = 0;
for (int i = 0; i < message.length(); i++) {
char c = message[i];
if (isalpha(c)) {
int shift = code[j] - 'a';
char encrypted_char = (c + shift - 'a') % 26 + 'A';
encrypted += encrypted_char;
j = (j + 1) % code.length();
}
else {
encrypted += c;
}
}
return encrypted;
}
string decrypt(string message, string code) {
string decrypted = "";
int j = 0;
for (int i = 0; i < message.length(); i++) {
char c = message[i];
if (isalpha(c)) {
int shift = code[j] - 'a';
char decrypted_char = (c - shift - 'A' + 26) % 26 + 'A';
decrypted += decrypted_char;
j = (j + 1) % code.length();
}
else {
decrypted += c;
}
}
return decrypted;
}
int main() {
string message, code;
cout << "Enter your message: ";
getline(cin, message);
cout << "Enter your secret code: ";
getline(cin, code);
string encrypted = encrypt(message, code); // encrypt the message using the code
cout << "Encrypted message: " << encrypted << endl; // print the encrypted message
string decrypted = decrypt(encrypted, code); // decrypt the encrypted message using the code
cout << "Decrypted message: " << decrypted << endl; // print the decrypted message
cout << endl;
cout << "Enter your encrypted message: ";
getline(cin, encrypted);
decrypted = decrypt(encrypted, code);
cout << "Decrypted message: " << decrypted << endl;
return 0;
}
i need help fixing my program so that the user can input both uper and.pdf

More Related Content

DOCX
PPTX
Presentat ions_PPT_Unit-2_OOP.pptx
PPT
Practical basics on c++
DOCX
PDF
Cryptography and network security record for cse .pdf
DOCX
Computer Networks Lab File
PDF
First c program
Presentat ions_PPT_Unit-2_OOP.pptx
Practical basics on c++
Cryptography and network security record for cse .pdf
Computer Networks Lab File
First c program

Similar to i need help fixing my program so that the user can input both uper and.pdf (20)

PDF
Computer Science Sample Paper 2015
PPT
Linux_C_LabBasics.ppt
DOCX
PPTX
C++ lectures all chapters in one slide.pptx
DOCX
C Programming
PPTX
Oops presentation
PDF
IT8761-SECURITY LABORATORY-590519304-IT8761 security labmanual.pdf
PPTX
C++ Code as Seen by a Hypercritical Reviewer
PDF
Computer science-2010-cbse-question-paper
PPT
operators in c language programming to improve c skills
PDF
COSCUP2023 RSA256 Verilator.pdf
DOCX
Cs pritical file
PPTX
c programs.pptx
PPTX
Control flow Graph
PPTX
Streaming and input output mOOPlec9.pptx
DOCX
Multi client
PDF
Asssignment2
PPTX
Fundamentals of functions in C program.pptx
PPT
Unit i intro-operators
PPTX
Chapter1.pptx
Computer Science Sample Paper 2015
Linux_C_LabBasics.ppt
C++ lectures all chapters in one slide.pptx
C Programming
Oops presentation
IT8761-SECURITY LABORATORY-590519304-IT8761 security labmanual.pdf
C++ Code as Seen by a Hypercritical Reviewer
Computer science-2010-cbse-question-paper
operators in c language programming to improve c skills
COSCUP2023 RSA256 Verilator.pdf
Cs pritical file
c programs.pptx
Control flow Graph
Streaming and input output mOOPlec9.pptx
Multi client
Asssignment2
Fundamentals of functions in C program.pptx
Unit i intro-operators
Chapter1.pptx
Ad

More from shreeaadithyaacellso (20)

PDF
In c++ Polymorphism is one of the hallmarks of OOP languages- What are (1).pdf
PDF
In Chapter 4 of LS- there is a case of Zappos and it describes how Zap.pdf
PDF
In C++ Plz LAB- Playlist (output linked list) Given main()- complete.pdf
PDF
In C Programming- not C++ Write a function which takes two formal pa.pdf
PDF
In chapter 17 you learned about the big picture of circulation through.pdf
PDF
In cell M11- enter a formula that will calculate the total amount due.pdf
PDF
In C++ Plz and In What Order Do I Put It In- LAB- Playlist (output li.pdf
PDF
In C++ Complete the program with the bold requirements #include #i.pdf
PDF
I am studying for a test tomorrow in my 494 Population Biology class-.pdf
PDF
I got the codes written down below- Basically- I am trying to implemen.pdf
PDF
I am trying to write a program that will converts a 32bit float number.pdf
PDF
I am stuck on this question- please show the solution step by step- Re.pdf
PDF
I et X and Y he two indenendent R(3n-1-3) random variables- Calculate.pdf
PDF
I am working on a coding project- and it asked me to combine five sets.pdf
PDF
I am needing to do a Point Factor Job Evaluation for a IT Company whos.pdf
PDF
i cant figure out this excel equation For the Year Ended December 31-.pdf
PDF
I am writing a program that will allow the user to move the crosshairs.pdf
PDF
I need simple java code for the below scenario- UML Diagrams(Class-Use.pdf
PDF
I need hlep I have posted this proble 4 times have gotten no help can.pdf
PDF
I need question 1 answer in java language- question 1)Create an applic.pdf
In c++ Polymorphism is one of the hallmarks of OOP languages- What are (1).pdf
In Chapter 4 of LS- there is a case of Zappos and it describes how Zap.pdf
In C++ Plz LAB- Playlist (output linked list) Given main()- complete.pdf
In C Programming- not C++ Write a function which takes two formal pa.pdf
In chapter 17 you learned about the big picture of circulation through.pdf
In cell M11- enter a formula that will calculate the total amount due.pdf
In C++ Plz and In What Order Do I Put It In- LAB- Playlist (output li.pdf
In C++ Complete the program with the bold requirements #include #i.pdf
I am studying for a test tomorrow in my 494 Population Biology class-.pdf
I got the codes written down below- Basically- I am trying to implemen.pdf
I am trying to write a program that will converts a 32bit float number.pdf
I am stuck on this question- please show the solution step by step- Re.pdf
I et X and Y he two indenendent R(3n-1-3) random variables- Calculate.pdf
I am working on a coding project- and it asked me to combine five sets.pdf
I am needing to do a Point Factor Job Evaluation for a IT Company whos.pdf
i cant figure out this excel equation For the Year Ended December 31-.pdf
I am writing a program that will allow the user to move the crosshairs.pdf
I need simple java code for the below scenario- UML Diagrams(Class-Use.pdf
I need hlep I have posted this proble 4 times have gotten no help can.pdf
I need question 1 answer in java language- question 1)Create an applic.pdf
Ad

Recently uploaded (20)

PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
RMMM.pdf make it easy to upload and study
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
master seminar digital applications in india
PPTX
Institutional Correction lecture only . . .
PDF
Computing-Curriculum for Schools in Ghana
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Basic Mud Logging Guide for educational purpose
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
Pharma ospi slides which help in ospi learning
PDF
Pre independence Education in Inndia.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
RMMM.pdf make it easy to upload and study
Anesthesia in Laparoscopic Surgery in India
Renaissance Architecture: A Journey from Faith to Humanism
master seminar digital applications in india
Institutional Correction lecture only . . .
Computing-Curriculum for Schools in Ghana
PPH.pptx obstetrics and gynecology in nursing
Basic Mud Logging Guide for educational purpose
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Cell Structure & Organelles in detailed.
102 student loan defaulters named and shamed – Is someone you know on the list?
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Microbial disease of the cardiovascular and lymphatic systems
Pharma ospi slides which help in ospi learning
Pre independence Education in Inndia.pdf
01-Introduction-to-Information-Management.pdf
Insiders guide to clinical Medicine.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
O5-L3 Freight Transport Ops (International) V1.pdf

i need help fixing my program so that the user can input both uper and.pdf

  • 1. i need help fixing my program so that the user can input both uper and lower case letters Write a new C++ program named Vigerene. use the rules of this website Code.org to return the message Code.org (Links to an external site.) Write the C++ program, Vigerene, which will prompt the user for a string message and a string secret code. The code must be shorter than the message. Then write a function which takes the message and code as parameters, and converts the two strings into a encrypted code using the rules on the code.org website. Return the encrypted message and print it in the Main class. Now write a new function which takes in an encrypted message and a secret code as two parameters and decrypts the the message and returns it to Main for printing. Here is sample output: Enter your messge: my name is rick Enter your secret code: helloworld TBKYOHSQTVGVTNY Enter your encrypted message TBKYOHSQTVGVTNY MY NAME IS RICK code: #include <iostream> #include <string> using namespace std; string encrypt(string message, string code) { string encrypted = ""; int j = 0; for (int i = 0; i < message.length(); i++) { char c = message[i]; if (isalpha(c)) { int shift = code[j] - 'a'; char encrypted_char = (c + shift - 'a') % 26 + 'A'; encrypted += encrypted_char; j = (j + 1) % code.length(); } else { encrypted += c;
  • 2. } } return encrypted; } string decrypt(string message, string code) { string decrypted = ""; int j = 0; for (int i = 0; i < message.length(); i++) { char c = message[i]; if (isalpha(c)) { int shift = code[j] - 'a'; char decrypted_char = (c - shift - 'A' + 26) % 26 + 'A'; decrypted += decrypted_char; j = (j + 1) % code.length(); } else { decrypted += c; } } return decrypted; } int main() { string message, code; cout << "Enter your message: "; getline(cin, message); cout << "Enter your secret code: "; getline(cin, code); string encrypted = encrypt(message, code); // encrypt the message using the code cout << "Encrypted message: " << encrypted << endl; // print the encrypted message string decrypted = decrypt(encrypted, code); // decrypt the encrypted message using the code cout << "Decrypted message: " << decrypted << endl; // print the decrypted message cout << endl; cout << "Enter your encrypted message: "; getline(cin, encrypted); decrypted = decrypt(encrypted, code); cout << "Decrypted message: " << decrypted << endl; return 0; }