Question

*Notes : Code With C++ Programming Language

Once upon a time there was a student who was quite smart on a campus. When he entered the time to work on his thesis, he had a dilemma. He is surrounded with various positive and negative energy auras from the surrounding environment.

Fortunately, this student was awarded a special ability, where he was able to convert negative energy into positive energy and then absorb it.

To be able to convert negative energy into positive one requires "Initial Positive Energy" (EPA). EPA is required to convert negative energy to positive with the following calculations:
a) If the amount of Negative Energy received is ODD, it takes 5 EPA to convert it into Positive Energy, then absorb it.

b) If the amount of Negative Energy received is EVEN, then it takes 4 EPA to convert it into Positive Energy, then absorb it.

c) If Positive Energy is received, then EPA is not needed, Positive Energy will be absorbed immediately. (All Positive Energy absorbed Will Not add value to EPA).

d) And if the remaining EPA is insufficient, the energy received will be directly absorbed WITHOUT any conversion.

e) EPA value is age minus 10. If the current age is 23, then EPA = 23 - 10 = 13.

f) After the Energy Conversion and Energy Absorption processes are complete, then:
Last Energy Remaining is = EPA residue + accumulated Absorbed Energy.
If the Last Energy Remaining:
- number is negative or 0, then the status is DO (DROP OUT).
- number is positive, then the status is PASS.
- number is positive and exceeds the age, then the status is PASS and CUMLAUDE.

Format Input

The first line is age.
The next line is the number of n energies that will be absorbed (For example, there are 5 energies, then n = 5).
The last line is the respective energy (input separated by a space).

Format Output

The first line output is Remaining Energy.
The next line output is the student's status (DROP OUT, PASS, CUMLAUDE)

Sample Input & Output (1) (standard input & output)

Enter the Age : 22 Enter the amount of energy that will be absorbed : 6 Enter the energies that will be absorbed : -6 5 -3 -7

Sample Input & Output (2) (standard input & output)

Enter the Age : 25 Enter the amount of energy that will be absorbed : 5 Enter the energies that will be absorbed : 2 -8 3 -5

Sample Input & Output (3) (standard input & output)

Enter the Age : 20 Enter the amount of energy that will be absorbed : 7 Enter the energies that will be absorbed : 10 -1 5 -3

Sample Input & Output (4) (standard input & output)

Enter the Age : 24 Enter the amount of energy that will be absorbed : 4 Enter the energies that will be absorbed : -1 -2 -3 -

Explanation (First Test Case):

Student aged 22 years (EPA = 22 - 10 = 12).
Absorbs 6 energies: -6 5 -3 0 -7 -2
Here's the process:
1) -6 will be changed to +6 by using 4 EPA (EPA remaining = 12 - 4 = 8), energy absorbed = 6
2) 5 will be absorbed immediately, the energy absorbed = 5
3) -3 will be changed to +3 using 5 EPA (EPA remaining = 8 - 5 = 3), energy absorbed = 3
4) 0 will be absorbed immediately, the energy absorbed = 0
5) -7 will be absorbed immediately because the EPA for conversion is insufficient, the energy absorbed = -7
6) -2 will be absorbed immediately because the EPA for conversion is insufficient, the energy absorbed = -2


Total Energy Absorbed = 6 + 5 + 3 + 0 + (-7) + (-2) = 5
Remaining EPA = 3
Last Energy Remaining = 5 + 3 = 8
Status = PASS!

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include<iostream>
using namespace std;
int main()
{
int age,amount_energy;
int array_amount[50];
cout<<"Enter the Age : ";
cin>>age;
cout<<"Enter the amount of energy that will be absorbed : ";
cin>>amount_energy;
cout<<"Enter the energies that will be absorbed : ";
for(int i=0;i<amount_energy;i++)
{
    cin>>array_amount[i];
}
cout<<"\n";

int epa=age-10;

for(int i=0;i<amount_energy;i++)
{
    if(array_amount[i]<0)
    {
        if(array_amount[i]%2==0)
        {
            if(epa>=4)
            {
                epa=epa-4;
                array_amount[i]=array_amount[i]*-1;
            }
        }
        else
        {
             if(epa>4)
            {
                epa=epa-5;
                array_amount[i]=array_amount[i]*-1;
            }
        }   
    }
}

int sum=epa;
for(int i=0;i<amount_energy;i++)
{
sum=sum+array_amount[i];

}

if(sum==0)
{
cout<<"No Energy left !";
cout<<"\nDO (DROP OUT) !";
}
else if(sum<0)
{
cout<<"The remaining energy is Negative Energy of = "<<sum;
cout<<"\nDO (DROP OUT) !";
}
else if(sum>0 && sum>age)
{
cout<<"The remaining energy is Positive Energy = "<<sum;
cout<<"\nPASS ! \nCUMLAUDE!"; 
}
else
{
cout<<"The remaining energy is Positive Energy of = "<<sum;
cout<<"\nPASS !";
}
cout<<"\n\n-------------------------------------\n";
}

Activities Visual Studio Code Mon Oct 12 3:27:36 PM O 85% energy.cpp - HomeworkLib - Visual Studio Code х File Edit Selection ViewActivities Visual Studio Code Mon Oct 12 3:27:40 PM O 85% energy.cpp - HomeworkLib - Visual Studio Code х File Edit Selection ViewActivities Visual Studio Code Mon Oct 12 3:27:42 PM O 85% energy.cpp - HomeworkLib - Visual Studio Code х File Edit Selection ViewActivities Visual Studio Code Mon Oct 12 3:29:40 PM O 85% energy.cpp - HomeworkLib - Visual Studio Code File Edit Selection View GoActivities Visual Studio Code Mon Oct 12 3:30:14 PM O 85% energy.cpp - Chegg - Visual Studio Code File Edit Selection View Go

If Answer is helpful , please upvote :)

Need any modifications , let me know :)

Add a comment
Know the answer?
Add Answer to:
*Notes : Code With C++ Programming Language Once upon a time there was a student who...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Bohr Model - Line Spectra 2 -0.07.ww Bohr's Model - Line Spectrum in eV:E, --13.6.1-1.2.3.4. SE-EE...

    Bohr Model - Line Spectra 2 -0.07.ww Bohr's Model - Line Spectrum in eV:E, --13.6.1-1.2.3.4. SE-EE Emitted lines Electrons in hydrogen atoms are in the n = 7 state (orbit). They can jump up to higher orbits or down to lower orbits. Emitted Spectral lines: When electrons in the higher orbits (with higher energies) jump DOWN to Lower orbits (with lower energies), energies are emitted in the form of emitted photons (light). The electrons jump from n = 7 state...

  • C++ programming language , I need help writing the code . Please explain if you can...

    C++ programming language , I need help writing the code . Please explain if you can . Exercise 10: Unit conversion (10 points) Write a console program that converts meters into feet and inches. The program starts by asking the user for a measurement in meters. The program should accept a floating point number. After getting the number, the program computes the number of feet and inches equal to the specified number of meters. The program outputs feet and inches...

  • Programming language C The third picture is the code that is being refactored Student 1:10 PM...

    Programming language C The third picture is the code that is being refactored Student 1:10 PM 3296.- Function Specifications [15 points 5 bonus points Use appropriate loops to ensure that if the user enters on incorrect value (out-of-range) mare hece-for an input, that the user is given an accurate messoge and provided an opportunity te enter the value egain (fer every input) Use an appropriate loop to allow the user to execute the program over and over again up to...

  • C PROGRAMMING LANGUAGE Door of the Ancient Pandy is at the last stage of "Door of...

    C PROGRAMMING LANGUAGE Door of the Ancient Pandy is at the last stage of "Door of the Ancients", his favorite video game. His objective is to pass through a sacred door. There are two ways to do this: By defeating a mighty guardian and snatch the key to the sacred door, or by destroying the sacred door (with brute force) directly. Pandy has no confidence in fighting the mighty guardian, thus Pandy opts to use the second method. Pandy has...

  • JUST GIVE ME THE C CODE FOR THIS QUESTION. I GOT THE ASSEMBLY CODE.

    JUST GIVE ME THE C CODE FOR THIS QUESTION. I GOT THE ASSEMBLY CODE. In this assignment, you will create a C program that iteratively populates a fixed-size integer array of 3 elements, array α.withhexadecimal integer valuesprovided by scanf. The user will enter 3 positive hexadecimal integer values, one per line, and the program will store the 3 values in arYay _afOJ,arvay aflJ, and crr ay_af2J. Once the 3 integers are entered, your program will print the array ain 32...

  • All information about the question (Task 1 and task 2) are down below Programming Assignments Task...

    All information about the question (Task 1 and task 2) are down below Programming Assignments Task 1 – Page 39. in Programming A Comprehensive Introduction Update your program from Assignment 2, Task #2 Allow the user to input their weight for the earth weight to moon weight conversion problem. Add an ifstatement that prompts the user if she inputs 0 or a negative number for her earth weight. #13. Mars’ gravity is about 17 percent less that of the earth’s....

  • I need help with this C code Can you explain line by line? Also can you...

    I need help with this C code Can you explain line by line? Also can you explain to me the flow of the code, like the flow of how the compiler reads it. I need to present this and I want to make sure I understand every single line of it. Thank you! /* * Converts measurements given in one unit to any other unit of the same * category that is listed in the database file, units.txt. * Handles...

  • Language is C programming Student ID should be 8 numbers long. create a program to read...

    Language is C programming Student ID should be 8 numbers long. create a program to read your student ID number and store it in an array. Input can not be hard wired, I have to be able to input my number Then change the first number to a letter. If the same number repeats in other parts of your student ID, you must change that number to a letter as well. print original array and modified array as your output....

  • C++ Write a program that takes in 3 inputs [players (int type), expected game time (double...

    C++ Write a program that takes in 3 inputs [players (int type), expected game time (double type), team (char type) and calculates actual game time (double) based on the following conditions: if the number of players or the expected game time is less than or equal to ZERO, it should output Wrong input if the number of players is greater than 0 and less than or equal to 6 and if they are on the 'R' or 'r' team, their...

  • Use C programming Make sure everything works well only upload Write a program that takes an...

    Use C programming Make sure everything works well only upload Write a program that takes an integer from standard input and prints all prime numbers that are smaller than it to standard output. Recall that a prime number is a natural number greater than 1 whose only positive divisors are 1 and itself. At the start of the program, prompt the user to input a number by printing "Input a number greater than 2:\n". If the user's input is less...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT