Questions
SOLVE IN C: Playing with encryption: Write a program that will read a four-digit integer entered...

SOLVE IN C: Playing with encryption:

Write a program that will read a four-digit integer entered by the user and encrypt it as follows: Replace each digit with the result of adding 7 to the digit and getting the remainder after dividing the new value by 10. Then swap the second digit with the fourth. Finally, print the original number and its encrypted one. Now reverse the process. Read an encrypted integer and decrypt it by reversing the algorithm to obtain the original number. Print out both the encrypted and decrypted integer.

need help finishing code on encryption in C I was assigned to encrypt and then decrypt a number by reversing the process to get it's original number. Here are the original instructions from my teacher:

I was able to encrypt, but now I am struggling with how to decrypt it back to it's original number. Here is my code:

You'll see my comment where I say I can't figure it out from a certain point and where the code needs to be fixed in bold.

#include
int main(){

int digit; // stores initial 4 digit integer value.
int digit1; // used to retrieve first digit.
int digit2; // retrieve second digit.
int digit3; // retrieve third digit.
int digit4; // retrieve fourth digit.
int swappedDigit; // the new encrypted digit value.

int decry; // stores initial 4 digit integer value.
int decry1; // first digit retrieval.
int decry2; // second digit retrieval.
int decry3; // third digit retrieval.
int decry4; // fourth digit retrieval.
int decrypt; // final decrypted digit.


printf("Enter a 4 digit number:\n");
scanf("%d", &digit);

/* the following 4 lines isolate each digit, as well as adding 7 to them and getting the remainder.
*/
digit1 = digit /1000 % 10;
digit1 = (digit1 + 7) % 10;


digit2 = digit /100 % 10;
digit2 = (digit2 + 7) %10;


digit3 = digit /10 % 10;
digit3 = (digit3 + 7) %10;


digit4 = digit % 10;
digit4 = (digit4 + 7) %10;

/* this formula below swaps the second and fourth numbers of the new decimal number from the formula above.
This gives us the new encrypted number. */

swappedDigit = (digit1 * 1000) + (digit2) + (digit3 * 10) + (digit4 * 100);

// printing the original number and the new encrypted number stored as "swappedDigit".
printf("The original digit is %d\n", digit);
printf("The encrypted digit is %d\n", swappedDigit);

// alerting the user to now input the same number to decrypt it by reversing the process.

printf("Now time to reverse the process.\n");
printf("Enter a 4 digit encrypted number:\n");
scanf("%d", &decry);


// this bottom part is all wrong. Not sure how to reverse it from here. Adding 3 only works for some numbers.

decry1 = decry /1000 % 10 + 3;
decry2 = decry /100 % 10 + 3;
decry3 = decry /10 % 10 + 3;
decry4 = decry % 10 + 3;

// swapping the second and fourth digits back to where they were originally.

decrypt = (decry1 * 1000) + (decry2) + (decry3 * 10) + (decry4 * 100);

// finally, printing the original decrypted number.

printf("The decrypted number is %d", decrypt);


   return 0;
}

In: Computer Science

O’Brien Company manufactures and sells one product. The following information pertains to each of the company’s...

O’Brien Company manufactures and sells one product. The following information pertains to each of the company’s first three years of operations:

Variable costs per unit:
Manufacturing:
Direct materials $26
Direct labor $16
Variable manufacturing overhead $3
Variable selling and administrative $1
Fixed costs per year:
Fixed manufacturing overhead $510,000
Fixed selling and administrative expenses $120,000

During its first year of operations, O’Brien produced 97,000 units and sold 80,000 units. During its second year of operations, it produced 84,000 units and sold 96,000 units. In its third year, O’Brien produced 82,000 units and sold 77,000 units. The selling price of the company’s product is $75 per unit.

2. Assume the company uses variable costing and a LIFO inventory flow assumption (LIFO means last-in first-out. In other words, it assumes that the newest units in inventory are sold first):

a. Compute the unit product cost for Year 1, Year 2, and Year 3

Unit Product Cost
Year 1
Year 2
Year 3

b. Prepare an income statement for Year 1, Year 2, and Year 3.

O’Brien Company
Variable Costing Income Statement
Year 1 Year 2 Year 3
Variable expenses:
Total variable expenses 0 0 0
0 0 0
Fixed expenses:
Total fixed expenses 0 0 0
$0 $0 $0

c. Assume the company uses absorption costing and a FIFO inventory flow assumption (FIFO means first-in first-out. In other words, it assumes that the oldest units in inventory are sold first):

d Compute the unit product cost for Year 1, Year 2, and Year 3. (Round your intermediate calculations and final answers to 2 decimal places.)

Unit Product Cost
Year 1
Year 2
Year 3

e Prepare an income statement for Year 1, Year 2, and Year 3. (Round your intermediate calculations to 2 decimal places.)

O’Brien Company
Absorption Costing Income Statement
Year 1 Year 2 Year 3
0 0 0
$0 $0 $0

In: Accounting

Utilizing the equal weighted series calculate the index values for each day for the market below....

Utilizing the equal weighted series calculate the index values for each day for the market below.

closing prices Number of outstanding shares(milions)
A B C A B C
1st jan 2020 200 400 300 100 200 100
2nd jan 2020 250 420 180 100 200 200
3rd jan 2020 270 450 80 100 600 200

In: Finance

Suppose that the MPC in a country is 0.7. Complete the following table by calculating the...

Suppose that the MPC in a country is 0.7.

Complete the following table by calculating the change in GDP predicted by the multiplier process given each fiscal policy change listed.

Fiscal Policy Change

Resulting Change in GDP

(Billions of dollars)

$100 billion increase in government spending (G)
$100 billion decrease in taxes (T)
$100 billion increase in government spending (G) and $100 billion increase in taxes (T)

In: Economics

PLEASE ANSWER IN DETAILS! What effect would each of the following events likely have on the...

PLEASE ANSWER IN DETAILS!

What effect would each of the following events likely have on the level of nominal interest rates?

a. Households dramatically increase their savings rate. (100 Words)

b. Corporations increase their demand for funds following an increase in investment opportunities. (100 Words)

c. The government runs a larger-than-expected budget deficit. (100 Words) d. There is an increase in expected inflation. (100 Words)

In: Finance

Pots and Things, a cookware retailer, sells a coffee machine to a customer for $150. The...

Pots and Things, a cookware retailer, sells a coffee machine to a customer for $150. The customer pays $100 in cash and puts the rest on her store credit account. Which one of the following statements describes the most appropriate accounting for the transaction?

  • Debit cash $100; debit accounts receivable $50; credit cost of good sold $150

  • Debit cash $100; debit accounts receivable $50; credit revenues $150

  • Debit revenues $150; credit cash $100; credit accounts receivable $50

  • Debit cash $100; debit accounts receivable $50; credit inventory $150

In: Accounting

You are given a mixture containing two compounds, A and B. Both compounds have a solubility...

You are given a mixture containing two compounds, A and B. Both compounds have a solubility of 1 g/ 100 mL of solvent at 20 °C and 16 g/ 100 mL of solvent at 100 °C. The sample is composed of 3.5 g of A and 10 g of B. At 100 °C the entire sample just dissolves in a minimum amount of solvent. The solution is cooled to 20 °C and crystals are collected.

Calculate the composition of the crystals and the yield of the process.

What is the composition of the mother liquor?

If the crystals obtained in question (1) are recrystallized from 100 mL of solvent, what will be the yield and composition of the crystals obtained?

In: Chemistry

during january, tedesco company sold 183 units of product k. It's beginning inventory and purchases during...

during january, tedesco company sold 183 units of product k. It's beginning inventory and purchases during the month were as following: january. 1- beginng inventory 100 units @ $41, january 5 -purchases 100 units @ $43, january 10 -purchases 100 units @ $38, january 15- purchases 100 units @ $50, january 20- purchases 100 units @ $48. Using the periodic inventory system compute the ending inventory and the cost of goods sold using the methods: a) average cost, b) FIFO, c) LIFO. SHOW ALL WORK

In: Accounting

In a simple two-sector Keynesian model, if MPC=75%, what is the size of the multiplier?   ...

In a simple two-sector Keynesian model, if MPC=75%, what is the size of the multiplier?
  
                
                

10. What is the equilibrium level of income in this Keynesian model?

        When DI (AP) = 1000, C=1200, Ip=300, G=200, Exports=100, Imports=50
        When DI (AP) = 2000, C=2000, Ip=300, G=200, Exports=100, Imports=100
        When DI (AP) = 3000, C=2800, Ip=300, G=200, Exports=100, Imports=150
        When DI (AP) = 4000, C=3600, Ip=300, G=200, Exports=100, Imports=200
        When DI (AP) = 5000, C=4000, Ip=300, G=200, Exports=100, Imports=250


  
                              1000          2000          3000          4000          5000

In: Economics

Create the pseudocode solution to a program that calculates the final score and letter grade for...

Create the pseudocode solution to a program that calculates the final score and letter grade for
one student. Please use the following grading system:
9 Homework Assignments – 100 points each 10 points
11 Quizzes – 100 points each 5 points
5 Projects – 100 points each 10 points
6 Discussion posts – 100 points each 10 points
4 Exams – 100 points each 65 points
A = 90 – 100% B = 80 – 89% C = 70 – 79% D = 60 – 69% F = 0 – 59%
Modify part 2 of the project by including repetitive structures, functions and input validation
(Chapters 5, 6 and 7). Try to reduce your code by reusing functions or modules that perform
similar tasks. Do not use arrays.

In: Computer Science