Write C Program Emulates Calculator Performs Following Operation Operation Must Implement Q43877453
Write a C program that emulates a calculator which performs thefollowing operation . Each operation must be implemented as afunction :
-Addition
-Subtraction
-Multiplication
-Division
Expert Answer
Answer to Write a C program that emulates a calculator which performs the following operation . Each operation must be implemented…
Write C Program Find Greatest Common Divisor Two Numbers Q43877400
Write a C program to find the greatest common divisor of twonumbers .
Expert Answer
Answer to Write a C program to find the greatest common divisor of two numbers ….
Write C Program Find Whether Given Year Leap Year Gregorian Calendar Three Criteria Must Q43835926
Write a C program to find whether a given yearis a leap year or not.
In the Gregorian calendar three criteria must be taken into accountto identify leap
years:
● The year can be evenly divided by 4;
● If the year can be evenly divided by 100, it is NOT a leap year,unless;
● The year is also evenly divisible by 400. Then it is a leapyear.
you can solve the question using the following statements ( if ,while , for ) , Try to make the solution as brief as youcan
Expert Answer
Answer to Write a C program to find whether a given year is a leap year or not. In the Gregorian calendar three criteria must be t…
Write C Program Finds Factorial Given Number Q43877377
Write a C program that finds the factorial of given number .
Expert Answer
Answer to Write a C program that finds the factorial of given number ….
Write C Program Fixes List Bank Card Numbers Miss One Digits Restore Digit Others Pair Adj Q43794613
Write a c++ program that fixes a list of bank card numbers. Someof them just miss one of digits and you should restore this digit.Others have a pair of adjacent digits swapped – you are to find theleftmost pair which, if swapped, makes valid cardnumber.
All the card numbers would be 16 digits long.
Input data contain a list of workers who havetheir card numbers incorrect.
Next lines contain a single card number each. If the numbercontains “?” (question mark) instead of some digit – this digitshould be restored. If all digits are present, then “swap-error”should be fixed.
Answer should contain a list of “fixed” cardnumbers.
input data:
4
?942682966937054 1217400151414995 2146133934?671142553514623364925
answer:
3942682966937054 1217040151414995 21461339346671142553514623369425
______________________________________________________________________________________
I need some help with my program. It is able to find a value toreplace the “?” with, but it does not find the right value for allof the test cases above. I also wrote a function(not included inbelow code), which use if statement to branch when the string doesnot contain “?” and deal with swap errors. For that, my approachwas to swap adjacent values, but I was able to get the right valueoutput to match the output sample above. I believe a map would behelpful to deal with this program, but I am not familiar with mapas data structures. I would appreciate your input. Since this is myfirst time trying to work with map, I would appreciate commentsinside the code. Also, I use Luhn Algorithm to check if a card isvalid or not.
—————————————————————————————————————————————————
#include <iostream>
#include <string>
#include <vector>
#include <array>
using namespace std;
void replace(int* a, int* b)
{
*b = *a;
}
void replace2(char* x, char* y)
{
*y = *x;
}
void eraseDemo(string str, int index)
{
str.erase(str.begin() + index);
}
int checkLuhn(string myString)
{
int x = myString.size();
int count = 0;
int val = 0;
int sum = 0;
char sign = ‘?’;
vector<int> arr;
size_t found = myString.find(sign);
if (found != string::npos)
{
eraseDemo(myString, found);
myString = myString;
x–;
}
while(count < x)
{
arr.push_back((int)myString[count] – 48);
count++;
}
int xx = arr.size()-1;
while(xx >= 0)
{
val = arr[xx] * 2;
if(val > 9)
{
val = val – 9;
}
replace(&val, &arr[xx]);
xx = xx – 2;
}
for(int ii = 0; ii < x; ++ii)
{
sum = sum + arr[ii];
}
return sum;
}
char Sum(string input)
{
int s = checkLuhn(input);
int ss = (s * 9) % 10;
char c = ss;
return c;
}
int main()
{
string x = “?942682966937054”;
char sign = ‘?’;
string result;
int mis = 0;
size_t found = x.find(sign);
mis = (checkLuhn(x) * 9) % 10;
Sum(x);
char s = ‘0’ + Sum(x);
replace2(&s , &x[found]);
cout << endl;
for(int xx = 0; xx < x.size(); xx++)
{
cout << x[xx];
}
cout << endl;
return 0;
}
Expert Answer
Answer to Write a c++ program that fixes a list of bank card numbers. Some of them just miss one of digits and you should restore …
Write C Program Following Ask User Enter Option Pick Infix Prefix Postfix Allow User Enter Q43810881
Write a C++ program that will do the following:
- Ask the user to enter the option to pick between infix, prefix,or postfix.
- Allow the user to enter a mathematical expression per theoption above.
- Allow the user to enter the option to pick between infix,prefix, or postfix.
- Ensure that the user does not pick the same exact optionagain.
- Validate that the expression entered is correct per the optionpicked in step 1.
- Evaluate the expression entered per the option selected in step1.
- Display the value produced in the above step.
- Convert the expression to be represented per the option pickedin step 3.
- Display the new expression after being converted in the abovestep.
- Evaluate the expression after being converted.
- Display the value produced in the above step.
Provide a screen shot of execution / output
Expert Answer
Answer to Write a C++ program that will do the following: Ask the user to enter the option to pick between infix, prefix, or postf…
Write C Program Following Write Function Finds Difference Two Numbers Function Gets 2 Inpu Q43858409
Write the Cprogram that does the following.
Write a function whichfinds the difference of two numbers. Your function gets 2 inputnumbers for example a and b and finds what is the difference ofthem, |a-b|. For example:
Difference(4, 8) =4
Expert Answer
Answer to Write the C program that does the following. Write a function which finds the difference of two numbers. Your function g…
Write C Program Gradec Includes Function Calculateaverage Calculate Average Arbitrary Numb Q43826010
write a C program, grade.c, which includes a function,
calculateAverage(), that can calculate the average ofan arbitrary number of test scores.
your program will not know in advance how many test scores willbe entered into your function
so you will need to use a sentinel value (-1) to terminate thewhile loop used to collect the test scores.
the test scores are integers in the range 0 to 100 and the testscore average should be output to two decimal places.
be sure that the user prompts and grades input into the programare displayed in the output file.
provided below is the main() function that I would likeyou to use for your program:
int main (void){
int I;
fopen_s(&fp, “csis.txt”, “w”);
for (i = 1; i <= 4; ++i) {
calculateAverage();
}
fclose(fp);
return 0;
}
please do not modify the main() function. it shouldappear as the first function in the program.
Be sure to use function prototypes for each of the functionsthat are used in your program.
Note that the first for loop invokes thecalculateAverage() function four times.
Each time the calculateAverage() function is invoked, adifferent set of test grades will be entered.
Please be sure to use the data shown below.
First: 78, 93, 45, 88, 89, -1
second: 87, 68, 100, -1
third: 84, 86, 90, 86, 96, 68, 82, -1
fourth: -1
Be sure that your code does not attempt to divide by zero forthe fourth run of the program.
Expert Answer
Answer to write a C program, grade.c, which includes a function, calculateAverage(), that can calculate the average of an arbitrar…
Write C Program Implement Functions 1 Function Returning Integer 2 Function Returning Floa Q43784676
Write any C# Program where You Implement these functions:
1. A function Returning an integer
2. A function Returning a Float
3. A function Returning a Double
4. A function Returning a String
5. A function Returning any array
6. A function Returning a pointer
7. Also, Implement the concept of array of pointers
You can Write any program as long as these functions existwithin. The goal is to have an understanding of these concepts.
Expert Answer
Answer to Write any C# Program where You Implement these functions: 1. A function Returning an integer 2. A function Returning a F…
Write C Program Input File Five Lines Create Five New Files File Contains One Line Q43865924
Write a c program. Input is a File with five lines.Create five new files, with each file contains one lineeach.
Expert Answer
Answer to Write a c program. Input is a File with five lines. Create five new files, with each file contains one line each….