6. Describe the motivation for the IP Security (IPsec) to become Internet standards.
In: Computer Science
C++ Pig Latin Lab
This assignment uses pointers to perform something done often in computer applications: the parsing of text to find “words” (i.e., strings delineated by some delimiter).
Write a program that encodes English language phrases into Pig Latin. Pig Latin is a form of coded language often used for amusement. Many variations exist in the methods used to form Pig Latin phrases. Use the following algorithm: to form a Pig Latin phrase from an English language phrase, tokenize the phrase into words with the C++ function strtok_s(). To translate each English word into a Pig Latin word, place the first letter of the English word at the end of the English word and add the letters “ay” after it. Thus, the word “jump” becomes “umpjay,” the word “the” becomes “hetay,” and the word “computer” becomes “omputercay.” Blanks between words remain as blanks. Assume that the English phrase input from the keyboard consists of words separated by blanks, there are no punctuations marks, all words have 2 or more letters, and the input phrase is less than 200 characters. Function printLatinWord() should display each word. Hint: Each time a token is found in a call to strtok_s(), pass the token pointer to function printLatinWord() and print the Pig Latin word.
Your program should allow the user to enter phrases until he or she selects an exit option to quit.
In summary: Create a Pig Latin program to implement this functionality: Prompt the user to enter a sentence. Print out the sentence, and then print out the same sentence in Pig Latin. Repeat this sequence until the user elects to quit.
Sol'n so far: (errors in lines 83 and 92)
#include <iostream>
#include <string>
using namespace std;
//class that hold strings of PigLatin
class PigLatin
{
//variable to Piglatin form word
private:
char *latin;
public:
//constructor that converts word into PigLatin
form
PigLatin(char *word)
{
//get the string length
int i, j = 0, len =
strlen(word);
//allocating space
latin = new char[len + 3];
//forming word
for (i = 1; i < len; i++)
{
latin[j] =
word[i];
j++;
}
//Adding last characters
latin[j] = word[0];
j++;
latin[j] = 'a';
j++;
latin[j] = 'y';
j++;
latin[j] = '\0';
}
//Function that returns the word in PigLatin
form
string getLatin()
{
string str(latin);
return str;
}
//Destructor to deallocate memory
~PigLatin()
{
delete[]latin;
}
};
//Function that receives the char * variable as parameter and prints its PigLatin form
void PrintLatinWord(char *str)
{
//creating an object of PigLatin class
PigLatin obj(str);
//Printing word in PigLatin form
cout << obj.getLatin() << " ";
}
//Main function
int main()
{
int i;
char str[200];
char *pch;
char option;
//Loop till user wants to quit
do
{
//Reading a phrase
cout << "\n\n Enter a
sentence to translated:";
cin.getline(str, 200);
//splitting words to
tokens
pch = strtok_s(str, " ");
cout << "\n\t";
//split enter phrase
completes
while (pch != NULL)
{
//Passing
token
PrintLatinWord(pch);
pch =
strtok_s(NULL, " ");
}
//Reading user option
cout << "\n\n Do you want to
enter another sentence? (Y - continue, N - Exit):";
cin.ignore();
} while (option != 'N' && option != 'n');
cout << endl;
system ("pause");
return 0;
}
In: Computer Science
In: Computer Science
Please show all work:
Multiplying the binary number below by decimal 128 yields ________
1 0 0 1 1 0 0 1 0 . 1 1 1 1 1 0 1 0 0 0 0 1 1 0 0 1
In: Computer Science
Write a Java programs.
Q.1. A freshman has 0-29 credits, a sophamore has 30-59, a junior has 60-89 and a senior has 90+ credits. Write a program to open the file and read all the contents. Report back to the user the number of freshmen, sophomores, juniors and seniors. Output the first and last names of the person with the highest GPA for each of those categories.
Q.2. (Occurrence of each letter) Write a Program that prompts the user to enter a file name and displays the occurrence of each letter in the file. Letters are case insensitive.
Students.java
The file students.txt has the following format on each line
fname(string) lname(string) credits(int) GPA(float) with a single space between each field.
For example
Mitchell Beck 11 2.88
Thelma Colon 43 2.25
Erma Mullins 68 1.98
Pedro Mack 17 1.95
.
In: Computer Science
Create a class called Cipher. Make the constructor accept some text and a key. Encrypt the given text using the key.
Use the following cipher:
Check the test cases for example.
Make getters to support the CipherDemo. Also, make two custom Exceptions called UselessKeyException and EmptyPlainText. In your constructor, throw UselessKeyException if the key is divisible by 26 and throw EmplyPainText if the plain text is zero characters.
CipherDemo.java :
import java.util.Scanner;
public class CipherDemo {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter some text to encrypt");
String input = keyboard.nextLine();
System.out.println("Enter a key");
int key = keyboard.nextInt();
try {
Cipher c = new Cipher(input, key);
System.out.println("Plain text: " + c.getPlainText());
System.out.println("Cipher text: " + c.getCipherText());
System.out.println("Key: " + c.getKey());
} catch (EmptyPlainText e) {
System.out.println(e.getMessage());
} catch (UselessKeyException e) {
System.out.println(e.getMessage());
System.out.println("Useless key: " + e.getUselessKey());
}
}
}
input
abcENTER 1ENTER
output:
Enter some text to encrypt\n Enter a key\n Plain text: abc\n Cipher text: bcd\n Key: 1\n
input:
Hello, my secret password is SIMCITY! Don't tell anyone! I've used this for 400 days.ENTER 23
output:
Enter some text to encrypt\n Enter a key\n Plain text: Hello, my secret password is SIMCITY! Don't tell anyone! I've used this for 400 days.\n Cipher text: EbiilC7jv7pbzobq7mxpptloa7fp7PFJZFQV87Alk>q7qbii7xkvlkb87F>sb7rpba7qefp7clo7KGG7axvpE\n Key: 23\n
input:
With computer science, you can work in any industry.ENTER 5021ENTER
output:
Enter some text to encrypt\n Enter a key\n Plain text: With computer science, you can work in any industry.\n Cipher text: Zlwk#frpsxwhu#vflhqfh/#brx#fdq#zrun#lq#dqb#lqgxvwub1\n Key: 5021\n
input:
With computer science, you can work in any industry.ENTER 26ENTER
output:
Enter some text to encrypt\n Enter a key\n Error: Key is divisible by 26. That's a bad key!\n Useless key: 26\n
input : 23
output:
Enter some text to encrypt\n Enter a key\n Error: Nothing to encrypt!\n
In: Computer Science
c++ class homework
Topics
If/Else If statement
Description
Write a program that determines a student’s final grade in the course. The course had three tests (100 points each) and four assignments (also 100 points each). All the test scores make up 70% of the grade and all the assignments 30% of the grade.
The program asks the user to input one by one each of the test scores and each of the assignment scores. From these scores, it computes the percentage of total points obtained by the user. It then determines the user’s final grade according to the table below.
90%-100% A
80%-89.99% B
70%-79.99% C
60%-69.99% D
0%-59.99% F
At the end, the program displays a summary report including: the original tests scores, the original assignment scores, the overall percentage points earned by the user and the final grade.
Requirements
Do the assignment using if/else if statement (not multiple if statements)
Test Data
Use the test data in test run 1 and test run 2 below
(input values are in bold)
(It's OK if your output does not show decimal values in exactly the same way.)
Input Test Run 1
Enter Scores Test 1: 90
Enter Scores Test 2: 90
Enter Scores Test 3: 90
Enter Scores Assignment 1: 90
Enter Scores Assignment 2: 90
Enter Scores Assignment 3: 90
Enter Scores Assignment 4: 90
Output Test Run 1
Summary Report
Test Scores: 90.0, 90.0, 90.0
Assignment Scores: 90.0, 90.0, 90.0, 90.0
Overall Percentage: 90.0%
Final Grade: A
Input Test Run 2
Enter Scores Test 1: 70
Enter Scores Test 2: 72
Enter Scores Test 3: 68
Enter Scores Assignment 1: 66
Enter Scores Assignment 2: 68
Enter Scores Assignment 3: 72
Enter Scores Assignment 4: 74
Output Test Run 2
Summary Report
Test Scores: 70.0, 72.0, 68.0
Assignment Scores: 66.0, 68.0, 72.0, 74.0
Overall Percentage: 70.0%
Final Grade: C
Submit
Copy the following in a file and submit that file.
Final output of test runs.
All the C/C++ source code.
Sample Code
/*
Declare variables t1, t2 and t3 for storing test scores and a1, a2, a3 and a4 for storing assignment scores. The variable pct is used for storing overall percentage. The variable grade is used for scoring the final letter grade
*/
double t1, t2, t3, a1, a2, a3, a4, pct;
string grade;
//write code below to input one by one the test and assignment scores in the above variables
//compute the overall percentage scores
pct = ( ( (t1 + t2 + t3 ) / 3.0 ) * .70 ) + ( ( ( a1 + a2 + a3 + a4 ) / 4.0 ) * .30 );
//compute final grade on the basis of pct scores using if/else if statement
if (pct >= 90) {
grade = "A";
}
else if (pct >= 80) {
grade = "B";
}
else if (pct >= 70) {
grade = "C";
}
//complete the above if/else if statement
In: Computer Science
Create an ASP.Net Website using Visual Studio with Visual Basic.Net:
Create a simple calculator that has 3 text boxes: 2 of them to enter numbers, the 3rd one displays the results
Create 4 buttons to add, subtract, multiply, and divide
Prevent the user from entering text in the number fields
Display a message indicating “cannot divide by” when the user click “/” and there is a zero the in the second box
Create two additional buttons:
- One to store data - The store data will store the results into array
- One to display data - The display data will display the contents of the array (use 10 for the array size)
In: Computer Science
Develop a Python program to identify the body-mass index of a collection of six individuals. Your program should include a list of six names. Note: If you chose to prompt for the names, build the list of names first, then do the following prompt for height, weight. Using a for loop, it should successively prompt the user for the height in inches and weight in pounds of each individual. Each prompt should display the name of the individual whose height and weight is to be input. Your program should validate that input for height and weight are positive. It should call a Function that accepts the height and weight as parameters and returns the body mass index for that individual using the formula: BMindex = weight × 703 / height2. (eg. 200lb, 6ft(72in) would be: BMindex = (200*703)/(72*72) = 27.1219 ). That body mass index should then be appended to a 2nd "parallel" array. Using a second loop it should traverse the array of body mass indices and call another function that accepts the body mass index as a parameter and returns whether the individual is underweight, normal weight or overweight. The number of individuals in each category should be counted and the number in each of those categories should be displayed. You should decide on the names of the at least six individuals and the thresholds used for categorization. Note: two loops and at least two functions. Display your name,class,date as per SubmissionRequirements by using a function.
In: Computer Science
4. What is ICMP and why is it important in data transferring? Give two examples of its usage. Also, explain why ICMP messages cannot be considered reliable.
In: Computer Science
- explain how the pseudo one-time pad works? What are its limitations?
In: Computer Science
I need a unique answer, NO COPY PLEASE!
Let us suppose we have 9 devices in a network. Explain what happens when a connection fails in the network arranged in the form of a:
In: Computer Science
Please show all work:
Represent the number (+46.5) as a 32 bit floating-point number using the IEEE standard 754 format. N.B. The attached ‘Appendix’ section may prove useful in the conversion process.
In: Computer Science
java
euclidean algorithm
(1) Let a = 35, and b = -49. Please compute GCD(a, b).
(2) Let a = 52, and b = 3. Please compute the quotient and remainder of a/b.
(3) Let a = -94, and b = 7. Please compute the quotient and remainder of a/b.
(4) Let a = 123, and b = 22. Please compute a mod b.
(5) Let a = -204, and b = 17. Please compute a mod b.
In: Computer Science
Please show all work:
Determine the 2’s complement equivalent of the following numbers in 8-bit format (N.B: You must show your work for full credit)!
In: Computer Science