Question

In: Computer Science

Complete the following exercises using C programming language. Take screenshots of the code and its output...

Complete the following exercises using C programming language. Take screenshots of the code and its output where specified and paste them into in a well-labeled Word document for submission.

Scenario

Assume you are the CIO of an organization with three different IT department locations with separate costs. You want a program to perform simple IT expenditure calculations. Your IT expenditure target is $35,000 per site.

Site expenditures:
Site 1 – $35,000.
Site 2 – $37,500.
Site 3 – $42,500.

Exercise 4 – Evaluating a Program’s Security

Examine the programs that you wrote and identify code that might have security-related implications. Explain a how that portion of code either enhances code security or introduces a security vulnerability.

Submit your well-labeled Word document that includes all elements specified in the exercises.

Solutions

Expert Solution

This is the brute-force method of security implementation:

Here is the code>>>

#include <stdio.h>
void checkExpenditure(int value){
int target=35000;
if(value>target) printf("The expenditure is exceed.\n");
else printf("The expenditure is not exceed.\n");
}
int main()
{
int site1=35000;
int site2=37500;
int site3=42500;
checkExpenditure(site1);
checkExpenditure(site2);
checkExpenditure(site3);

return 0;
}

Here is the live output of the program>>>

Security Implications>>>

  • This ensures that if the expenditure is exceeded then the administrator gets notified as a message with proper information.
  • As this solves the basic problem of informing the administrators. But there are some problems still in the problem.
    • Firstly if the expenditure can't be zero or minus, but there is no check about this in the program. Let us solve the problem.

Here is a more secure implementation>>>

#include <stdio.h>
void checkExpenditure(int value){
if(value>0){
int target=35000;
if(value>target) printf("The expenditure is exceed.\n");
else printf("The expenditure is not exceed.\n");
}else printf("Invalid expenditure entered.\n");
}
int main()
{
int site1=35000;
int site2=37500;
int site3=42500;
int site4=-1;
int site5=0;
checkExpenditure(site1);
checkExpenditure(site2);
checkExpenditure(site3);
checkExpenditure(site4);
checkExpenditure(site5);


return 0;
}

Here are the live output and code snippet>>>

Security Implications:

  • In the above implementation, another problem is solved which was to tackle the zero or invalid condition.
  • But there is another issue at hand. If the user enters any float number which is not a full number the program can't handle the situation. Let's handle the situation.

Here is the updated code>>>

#include <stdio.h>
void checkExpenditure(float value){
if(value>0){
float target=35000.00f;
if(value>target) printf("The expenditure is exceed.\n");
else printf("The expenditure is not exceed.\n");
}else printf("Invalid expenditure entered.\n");
}
int main()
{
float site1=35000.4f;
int site2=37500;
float site3=42500.5f;
int site4=-1;
int site5=0;
checkExpenditure(site1);
checkExpenditure(site2);
checkExpenditure(site3);
checkExpenditure(site4);
checkExpenditure(site5);


return 0;
}

Here is the code output>>

Security Implications:

  • After these three updates, the code has solved three problems.
    • Firstly the code is more rigid by handling the zero or minus condition.
    • Secondly, the code sends feedback to the administrator.
    • Thirdly the program handles the float values as well.

Related Solutions

Exercises Code of Conduct Exercises Instructions:  Answer the following in complete sentences using the AICPA's revised Code...
Exercises Code of Conduct Exercises Instructions:  Answer the following in complete sentences using the AICPA's revised Code of Conduct, providing the ET references for each of your responses. For questions with multiple parts, include multiple ET references as appropriate. What are the three broad categories of safeguards identified in Part 1 of the Code, in the Conceptual Framework for members in public practice? Which category of safeguard cannot be relied upon, by itself, to reduce threats to an acceptable level?
C Programming Language (Code With C Programming Language) Problem Title : Which Pawn? Jojo is playing...
C Programming Language (Code With C Programming Language) Problem Title : Which Pawn? Jojo is playing chess himself to practice his abilities. The chess that Jojo played was N × N. When Jojo was practicing, Jojo suddenly saw a position on his chessboard that was so interesting that Jojo tried to put the pieces of Rook, Bishop and Knight in that position. Every time he put a piece, Jojo counts how many other pieces on the chessboard can be captured...
In C++, Complete the Code & Show the output. Schedule the following process using Shortest Job...
In C++, Complete the Code & Show the output. Schedule the following process using Shortest Job First Scheduling algorithm Porcress Burst time Arrival time 1 8 0 2 2 0 3 1 0 4 4 0 Compute the following and show the output a) Individual Waiting time & Turnaround time b) Average Waiting time & Turnaround time c) Display the Gantt chart (Order of Execution)    #include using namespace std; //structure for every process struct Process { int pid; //...
Please code the program showing the output below. using C language 1. Using 'if' or 'while'...
Please code the program showing the output below. using C language 1. Using 'if' or 'while' or 'for' and 'break' statement / only using <stdio.h> A bC dEf GhIj KlMnO 2. a program that identifies the largest number that can be expressed in short. Using only loop (ex.for,if,while) and break statement only using <stdio.h>
Complete the following assignment in C programming language. Get the user’s first name and store it...
Complete the following assignment in C programming language. Get the user’s first name and store it to a char array Declare a character array to hold at least 20 characters. Ask for the user’s first name and store the name into your char array. Hint: Use %s for scanf. %s will only scan one word and cannot scan a name with spaces. Get 3 exam scores from the user: Declare an array of 3 integers Assume the scores are out...
Complete the following assignment in C programming language. Get the user’s first name and store it...
Complete the following assignment in C programming language. Get the user’s first name and store it to a char array Declare a character array to hold at least 20 characters. Ask for the user’s first name and store the name into your char array. Hint: Use %s for scanf. %s will only scan one word and cannot scan a name with spaces. Get 3 exam scores from the user: Declare an array of 3 integers Assume the scores are out...
Write a code in C or C++ programming language that generates the hexadecimal values in Table...
Write a code in C or C++ programming language that generates the hexadecimal values in Table 6-2 in the same format. Table 6-2 Hexadecimal text file specifying the contents of a 4 × 4 multiplier ROM. 00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 20: 00 02 04 06 08 0A 0C 0E 10...
Complete the following assignment in C programming language. 1. Declare the following float variables: -Maximum exam...
Complete the following assignment in C programming language. 1. Declare the following float variables: -Maximum exam score, user's exam score, and percentage. 2. Ask the user to input data into your variables, such as: -"What is the max score of your exam:" -"What was your score:" 3. Use if statements to validate user inputs. For example, score received should not be more than maximum possible score. -Display an error message when the user enters invalid data. -You can restart the...
In C Programming Language Write a program to output to a text log file a new...
In C Programming Language Write a program to output to a text log file a new line starting with day time date followed by the message "SUCCESSFUL". Please screenshot the results.
in C programming language, write and test a function that writes and returns through an output...
in C programming language, write and test a function that writes and returns through an output parameter the longest common suffix of two words. (e.g. The longest common suffix of "destination" and "procrastination" is "stination", of "globally" and "internally" is "ally, and of "glove" and "dove" is the empty string)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT