CODE:
#include<stdio.h>
#include<stdlib.h>
#define MAX_LIMIT 10
void getCalories(int steps,int weight)
{
float calories= -1968.76 -
324.229*(steps*1.0/2250)*22.947*weight;
printf("%f",calories);
}
int main()
{
printf("This program will calculate the amount of calories burnes
while taking x number of steps while walking\n");
int c;
do
{
printf("Enter steps and weight ");
int steps=0;
int weight=0;
scanf("%d",&steps);
scanf("%d",&weight);
int error=0;
int counter=0;
while(steps<0 || weight<=0) //wrong input
{
counter++;
printf("Wrong input. Trial remaing %d\n",MAX_LIMIT-counter);
if(counter>=MAX_LIMIT)
{
error = 1;
break;
}
printf("Enter steps and weight ");
scanf("%d",&steps);
scanf("%d",&weight);
}
if(error)
{
printf("You have crossed the number of invalid attempts\n");
break;
}
getCalories(steps,weight);
printf("\ntype 0 to exit / any number to continue");
scanf("%d",&c);
}while(c);
return 0;
}
OUTPUT:
please provide positive feedback if it helped
Programming language C The third picture is the code that is being refactored Student 1:10 PM...
This is done in c programming and i have the code for the programs that it wants at the bottom i jut dont know how to call the functions Program 2:Tip,Tax,Total int main(void) { // Constant and Variable Declarations double costTotal= 0; double taxTotal = 0; double totalBill = 0; double tipPercent = 0; // *** Your program goes here *** printf("Enter amount of the bill: $"); scanf("%lf", &costTotal); printf("\n"); // *** processing *** taxTotal = 0.07 * costTotal; totalBill...
Write a program that asks the user to type an even number or 111 to stop. When the user types an even number, display the message “Great Work”, and then ask for input again. When the user types an odd number, display the message “Try again” and ask the user to enter again. When the user enters the sentinel value of 111 the program ends I've attempted this but it went horribly wrong. we are only suppose to use while,...
In C programming language: This program will output a right triangle based on user specified height triangleHeight and symbol triangleChar. (1) The given program outputs a fixed-height triangle using a * character. Modify the given program to output a right triangle that instead uses the user-specified triangleChar character. (1 pt) (2) Modify the program to use a nested loop to output a right triangle of height triangleHeight. The first line will have one user-specified character, such as % or *....
IT Java code In Lab 8, we are going to re-write Lab 3 and add code to validate user input. The Body Mass Index (BMI) is a calculation used to categorize whether a person’s weight is at a healthy level for a given height. The formula is as follows: bmi = kilograms / (meters2) where kilograms = person’s weight in kilograms, meters = person’s height in meters BMI is then categorized as follows: Classification BMI Range Underweight Less...
the coding language is just the basic c language and here is my first attempt at this problem my problem is that if the user inputs a number that is equal to a number that has been entered previously the code will never end until the user enters a number that is bigger than any other number previously entered any help will be helpful Write a program to read-in a sequence of integers from the keyboard using scanf(). Your program...
Having trouble with the do while/while loop and the switch statement. I got some of the switch statement but cant get the program to repeat itself like it should.What i have so far for my code is below. Any help is appreciated... i am not sure what I am doing wrong or what i am missing. I am completely lost on the while loop and where and how to use it in this scenario. import java.util.Scanner; public class sampleforchegg {...
Java Programming Language Edit and modify from the given code Perform the exact same logic, except . . . The numeric ranges and corresponding letter grade will be stored in a file. Need error checking for: Being able to open the text file. The data makes sense: 1 text line of data would be 100 = A. Read in all of the numeric grades and letter grades and stored them into an array or arraylist. Then do the same logic....
Step 4: Add code that discards any extra entries at the propmt that asks if you want to enter another score. Notes from professor: For Step 4, add a loop that will validate the response for the prompt question: "Enter another test score? (y/n): " This loop must only accept the single letters of ‘y’ or ‘n’ (upper case is okay). I suggest that you put this loop inside the loop that already determines if the program should collect...
Please I need help in C language, I am trying to modify the code per the below instructions, but I am getting errors. Can't fgure it out. The attempted code modification and data file is privided below, after the instructions. Thank you. Instructions: 1. First, add a function named printMsg that displays a message, a greeting, or an introduction to the program for the user. Add a statement that calls that function from the main function when your program starts....
Working in C, modify the algorithm created in the Topic 1 assignment "Non-Linear Flow Chart" to instead compute the nth term in the series by calling a recursive function. Note that the value of "n" will need to be an input argument, along with the two starting values of the series. Discuss the efficiency of this method versus the iterative logic that you wrote previously. Previous Code: //main.c #include<stdio.h> #include<limits.h> int main() { //declare a integer data type variales...