cse320validargs
.
keyboard_arrow_up
School
Stony Brook University *
*We aren’t endorsed by this school
Course
320
Subject
Computer Science
Date
Jan 9, 2024
Type
Pages
5
Uploaded by PresidentHeat8133
#include <stdlib.h>
#include "reverki.h"
#include "global.h"
#include "debug.h"
int convertStrtoInt(char *str);
/**
* @brief Validates command line arguments passed to the program.
* @details This function will validate all the arguments passed to the
* program, returning 0 if validation succeeds and -1 if validation fails.
* Upon successful return, the various options that were specified will be
* encoded in the global variable 'global_options', where it will be
* accessible elsewhere in the program. For details of the required
* encoding, see the assignment handout.
*
* @param argc The number of arguments passed to the program from the CLI.
* @param argv The argument strings passed to the program from the CLI.
* @return 0 if validation succeeds and -1 if validation fails.
* @modifies global variable "global_options" to contain an encoded representation
* of the selected program options.
*/
int validargs(int argc, char **argv) {
if (argc < 1){ // if there are no arguments given return -1;
}
if (argc == 1) { // if there is only one argument return -1; }
if ( *(*(argv + 1)) == '-' && *((*(argv + 1)) + 1) == 'h'){ // regardless
of the other arguments if arg1 is -h ignore other flags printf("success -h ignore other arguments");
global_options = HELP_OPTION;
return 0;
}
if(argc == 2) { // if there's 2 arguments and it's one of the positional arguments -h or -v or -r
if ( *(*(argv + 1)) == '-' && *((*(argv + 1)) + 1) == 'h'){ // arg1 is -h
printf("success -h only");
global_options = HELP_OPTION;
return 0;
}
if ( *(*(argv + 1)) == '-' && *((*(argv + 1)) + 1) == 'v'){ // arg1 is -v
printf("success -v only");
global_options = VALIDATE_OPTION ;
return 0;
}
if ( *(*(argv + 1)) == '-' && *((*(argv + 1)) + 1) == 'r'){ // arg1 is -r
printf("success -r only");
global_options = REWRITE_OPTION;
return 0;
}
else { //if the first flag isn't -h or -v or -r then return -1 for exit_failure
printf("failure neither -h, -v or -r are first"); return -1;
}
}
if(argc >= 3) { if(argc==3) { //if there's only 2 flags if ( *(*(argv + 1)) == '-' && *((*(argv + 1)) + 1) == 'v') { //if its -v -s
if(*(*(argv+1)+2) == '\0') {
if(*(*(argv+2)) == '-' && *(*(argv+2)+1) == 's') {
printf("in -v -s success");
global_options = VALIDATE_OPTION | STATISTICS_OPTION;
return 0;
}
}
} if ( *(*(argv + 1)) == '-' && *((*(argv + 1)) + 1) == 'r') { //if its -r -s
if(*(*(argv+1)+2) == '\0') {
if(*(*(argv+2)) == '-' && *(*(argv+2)+1) == 's') {
printf("in -r -s success");
global_options = REWRITE_OPTION | STATISTICS_OPTION;
return 0;
}
}
}
if ( *(*(argv + 1)) == '-' && *((*(argv + 1)) + 1) == 'r') { //if its -r -t
if(*(*(argv+1)+2) == '\0') {
if(*(*(argv+2)) == '-' && *(*(argv+2)+1) == 't') {
printf("in -r -t success");
global_options = REWRITE_OPTION | TRACE_OPTION;
return 0;
}
}
} }
//if there's more than 3 arguments if ( *(*(argv + 1)) == '-' && *((*(argv + 1)) + 1) == 'r') { //if its -r -l
[#LIMIT]
if(*(*(argv+1)+2) == '\0') {
if(*(*(argv+2)) == '-' && *(*(argv+2)+1) == 'l') {
//*(*(argv+2)+1) == 'l' int limitSteps = convertStrtoInt(*(argv + 3));
if(limitSteps > 0 || limitSteps < 2147483647) { //checking if limit
is within the range [1, 2^31-1]
long limit = (long)limitSteps; //converting from int to long int to
store in global options which is in long int
limit = limit << 32;
global_options = REWRITE_OPTION | LIMIT_OPTION | limit;
// printf("after: %X\n",limit); printf("in -r -l success");
global_options = REWRITE_OPTION | LIMIT_OPTION;
return 0;
}
else {
//limit out of range printf("failure limit out of range");
return -1;
}
}
}
}
//all other valid argument combinations //Three combos: -r -s -t, -r -t -s, -r -l -t, -r -t -l, -r -s -l, -r -l -s
if ( *(*(argv + 1)) == '-' && *((*(argv + 1)) + 1) == 'r') { //-r -s -t
if(*(*(argv+1)+2) == '\0') {
if(*(*(argv+2)) == '-' && *(*(argv+2)+1) == 's') {
if(*(*(argv+1)+3) != '\0') { if(*(*(argv+3)) == '-' && *(*(argv+3)+1) == 't') {
printf("in -r -S -t success");
global_options = REWRITE_OPTION | STATISTICS_OPTION
| TRACE_OPTION;
return 0;
}
} }
}
}
if ( *(*(argv + 1)) == '-' && *((*(argv + 1)) + 1) == 'r') { //-r -t -s
if(*(*(argv+1)+2) == '\0') {
if(*(*(argv+2)) == '-' && *(*(argv+2)+1) == 't') {
if(*(*(argv+1)+3) != '\0') { if(*(*(argv+3)) == '-' && *(*(argv+3)+1) == 's') {
printf("in -r -t -s success");
global_options = REWRITE_OPTION | TRACE_OPTION | STATISTICS_OPTION ;
return 0;
}
} }
}
}
if ( *(*(argv + 1)) == '-' && *((*(argv + 1)) + 1) == 'r') { //-r -t -l
if(*(*(argv+1)+2) == '\0') {
if(*(*(argv+2)) == '-' && *(*(argv+2)+1) == 't') {
if(*(*(argv+1)+3) != '\0') { if(*(*(argv+3)) == '-' && *(*(argv+3)+1) == 'l') {
int limitSteps = convertStrtoInt(*(*(argv+4));
if(limitSteps > 0 || limitSteps < 2147483647) { //checking if limit
is within the range [1, 2^31-1]
long limit = (long)limitSteps; //converting from int to long int to
store in global options which is in long int
limit = limit << 32;
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
/* Program Name: BadDate.cpp
Function: This program determines if a date entered by the user is valid.
Input: Interactive
Output: Valid date is printed or user is alerted that an invalid date was entered
*/
#include <iostream>
bool validateDate(int, int, int);
using namespace std;
int main()
{
// Declare variables
int year;
int month;
int day;
const int MIN_YEAR = 0, MIN_MONTH = 1, MAX_MONTH = 12, MIN_DAY = 1, MAX_DAY = 31;
bool validDate = true;
// This is the work of the housekeeping() method
// Get the year, then the month, then the day
// This is the work of the detailLoop() method
// Check to be sure date is valid
if(year <= MIN_YEAR) // invalid year
validDate = false;
else if (month < MIN_MONTH || month > MAX_MONTH) // invalid month
validDate = false;
else if (day < MIN_DAY || day > MAX_DAY) // invalid day
validDate = false;
// This is the work of the endOfJob()…
arrow_forward
None
[] # Don't write code in this line
Q5: Complete the function that calculates the position of an object at any time t> 0. The initial position and the initial velocity (at time t=0) are denoted as so and v0 respectively. The object undergoes constant acceleration a, for any time t>0.
[ ]: def calculate_position (s0,u,a,t):
"given the initial conditions and acceleration, return the object's position.
Use the variable named 'position' to hold and return this value """
# YOUR CODE HERE
return position
I
↑↓古早
Check your code here "
Assign random input variables and check the answer"
arrow_forward
Option #1: String Values in Reverse Order
Assignment Instructions
Write a Python function that will accept as input three string values from a user. The method will return to the user a concatenation of the string values in reverse order. The function is to be called from the main method.
In the main method, prompt the user for the three strings.
arrow_forward
Functions and Optionals - How do I do this practice exercise using Swift code?
arrow_forward
PROGRAMMING LANGUAGE: C++
TASK 1. You are required to create a simulation of an elevator system. There are 7 floors in a building. A user may enter the elevator and press the button of the destined floor. The simulation should display appropriate messages while moving towards the destined floor.
Task 2. Write a program that takes +,-,*, and / operators and performs the required operation. the program will continue to execute until ESC key is pressed. Also, the usage of post-test loop and switch statement is mandatory.
arrow_forward
#include <stdio.h>#include <string.h>
#pragma warning(disable : 4996) // compiler directive for Visual Studio only
// Read before you start:// You are given a partially complete program. Complete the functions in order for this program to work successfully.// All instructions are given above the required functions, please read them and follow them carefully. // You shoud not modify the function return types or parameters.// You can assume that all inputs are valid. Ex: If prompted for an integer, the user will input an integer.// You can use only the strlen() of strings.h library to check string length. Do not use any other string functions // because you are supposed to use pointers for this homework. // **** DO NOT use arrays to store or to index the characters in the string ****
// Global Macro Values. They are used to define the size of 2D array of characters#define NUM_STRINGS 4#define STRING_LENGTH 50
// Forward Declarationsvoid…
arrow_forward
11 Worksheet 5
Note:Solution using Matlab Code
Write a program that prompts the user to enter a number within the range of 1 through 7, those
numbers represent the weekdays as shown in the table. If the entered number is more than 7,
display 'invalid day'.
Number
1
2
3
4
5
6
7
Day
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Type of the day
Workday
Workday
Workday
Workday
Workday
Weekend
Weekend
The program should continue to repeat itself 10 times, after which, the program should stop.
Furthermore, the program should be able to show a message saying if this is a 'workday' or a
'weekend day'.
Note: you are required to add a comment beside your command. Hint: to add a comment you
may use the % sign. thank guys you dodo great.
arrow_forward
Python
get_user_input(message, sentinel):
The parameter message is the string message to request an integer from the user.
The parameter sentinel is the unique character that signals the end of input.
This function will return value: done, The parameter done is a Boolean flag that signals that the user entered a sentinel value and the value is invalid.
main():
calling the get_user_input function until the sentinel value is detected
capture the output from the get_user_input function into two variables
use the Boolean flag return value to control the loop in main
store the integer return value to a Python list
The program will print the integers entered back to the user only after the sentinel value is detected
arrow_forward
C++ beginner
arrow_forward
please correct this code i didnt get the mistake
#include<stdio.h>#define NROWS 8#define NCOLS 8#define TRUE 1#define FALSE 0
void main(){ int queenht_row, queenht_col; int line,row,col,i,j; int filled; printf("Chess queenht Program\n"); do{ printf("Enter queenht's coordinates: "); scanf("%d %d",&queenht_row,&queenht_col); }while((queenht_row<1)||(queenht_row>NROWS)||(queenht_col<1)||(queenht_col>NCOLS)); for(line=1;line<=2*NROWS+1;line++){ row = line/2; if(line%2!=0){ printf("+"); for(col=1;col<=NCOLS;col++) printf("---+"); printf("\n"); } else{ printf("|"); for(col=1;col<=NCOLS;col++){ filled=FALSE; if((row==queenht_row) && (col==queenht_col)){ printf(" Q |"); filled = TRUE; continue; }…
arrow_forward
#include <stdio.h>#include <stdlib.h>
//declaring variables globally to calculate coinsint cent50 = 0;int cent20 = 0;int cent10 = 0;int cent05 = 0;
//calculate change//pass change variable by addressvoid calculateChange(int* change) {//calculate change only if change is positiveif(*change > 0) {if(*change >= 50) {*change -= 50;cent50++;}else if(*change >= 20) {*change -= 20;cent20++;}else if(*change >= 10) {*change -= 10;cent10++;}else if(*change >= 05) {*change -= 05;cent05++;}//call calculateChange recursively calculateChange(change);}}
// function to display the cents valuesvoid printChange() {
if(cent50)printf("\n50 Cents : %d coins", cent50);if(cent20)printf("\n20 Cents : %d coins", cent20);if(cent10)printf("\n10 Cents : %d coins", cent10);if(cent05)printf("\n05 Cents : %d coins", cent05);//reset all cent variables with 0cent50 = 0;cent20 = 0;cent10 = 0;cent05 = 0;
}
//take change input from user//change variable passed addressvoid TakeChange(int*…
arrow_forward
Program Requirements
This program should add numbers 1 through 9 one a time, via a button click, display the result, and allow the user to Clear the total to zero.
Your Starter Codeworks for numbers 1 through 3. Give it a try, push the buttons, to see what it does.
Extending Structured Programs is Easy
In this assignment, you use existing code to:
identify the patterns in a program
modify the patterns in order to extend the functionality of the program
Your Task for this Assignment
Requirements: Extend this program to create the 6 more HTML buttons and 6 more Javascript functions.
Software Development Best Practice: Incremental Development
Do not program all your code at once like you were editing some essay. Making a big mess and then trying to patch it up all one once... is a nightmare.
Add one button and its function
Test it
Repeat with the next button
Pattern One: HTML Button
Add your HTML code where the highlighted area is in the image below. Copy an existing button, and…
arrow_forward
How many edges does your polygon have? 6 This is a hexagon. --- Sample run: This is a rectangle. Shape not recognized. How many edges does your polygon have? 3 This is a triangle.
arrow_forward
Add comments!Help me prgram this please and thanks!
arrow_forward
Direction: Read each sentence/ situation carefully and select the BEST answer among the choices.
1. It is a Boolean expression that tells when the loop will exit.
2. The sequence that makes up the loop body may either be a block of Turbo C statements or a single Turbo C statement.
3. In Turbo C it is a reserved word.
4. Its values determine the number of times the loop iterates.
5. It is the second type of open-ended loop.
Condition
For Loop
Statement
For
Do while Loop
arrow_forward
// LargeSmall.cpp - This program calculates the largest and smallest of three integer values.
#include <iostream>
using namespace std;
int main()
{
// This is the work done in the housekeeping() function
// Declare and initialize variables here
int largest; // Largest of the three values
int smallest; // Smallest of the three values
// Prompt the user to enter 3 integer values
// Write assignment, add conditional statements here as appropriate
// This is the work done in the endOfJob() function
// Output largest and smallest number.
cout << "The largest value is " << largest << endl;
cout << "The smallest value is " << smallest << endl;
return 0;
}
arrow_forward
Python:Temperature Statistics
Learning Objectives
In this lab, you will
Create a function to match the specifications
Use the if/else statements to detect a range
Use lists to store the results
Instructions
Sahara desert explorers call us for help! They want to know some statistics about the temperature in Sahara, but sometimes their thermometer fails to record the proper temperature. Help them to find which temperature is from correct recordings and which is broken and calculate statistics on given data.
During the night, the temperature in Sahara varies from -4 to -10 С. During the day, the temperature varies from 20 to 50 C.
Create a function check_input(temperature) that will return True if the temperature given as input can be from Sahara and False if it is from a broken thermometer (i.e., outside of the expected range).
Steps
Write a program to use the check_input to create a list of valid temperatures and compute their statistics:
Create a list, where you will store the…
arrow_forward
Assignment #2 Instructions:
Through this programming assignment, the students will learn to do the following:
Learn to work with command line options and arguments
Gain more experience with Makefiles
Gain more experience with Unix
Learn to use some of the available math functions available with C
Usage: mortgagepmt [-s] -r rate [-d downpayment] price
In this assignment, you are asked to perform a mortgage payment calculation. All information needed for this will be passed to the program on the command line. There will be no user input during the execution of the program
You will need a few pieces of information. The price of the home and the amount of the down payment. You will also need to know the interest rate and the term of the mortgage. To figure your mortgage payment, start by converting your annual interest rate to a monthly interest rate by dividing by 12. Next, add 1 to the monthly rate. Third, multiply the number of years in the term of the mortgage by 12 to calculate the…
arrow_forward
Flowchart for student interface program please.
Create a program to enter grades and calculate averages and letter grades.
Need a class which will contain:
Student Name
Student Id
Student Grades (an array of 3 grades)
A constructor that clears the student data (use -1 for unset grades)
Get functions for items a, b, and c, average, and letter grade
Set functions for items a, n, and c
Note that the get and set functions for Student grades need an argument for the grade index.
Need another class which will contain:
An Array of Students (1 above)
A count of number of students in use
You need to create a menu interface that allows you to:
Add new students
Enter test grades
Display all the students with their names, ids, test grades, average, and letter grade
Exit the program
Add comments and use proper indentation.
Nice Features:
I would like that system to accept a student with no grades, then later add one or more grades, and when all grades are entered, calculate the final…
arrow_forward
Usernames
An online company needs your help to implement a program that verifies the username chosen by a new user. Their rules is described below:
Username MUST contain at least 6 characters;
Username cannot start with a number;
Username can only contain letters or numbers.
If valid, the username may be resgistered if it doesn't already exist in the system.
You should not use built-in functions to determine the character type such as isnumeric() or islower().
Use the strings given alphabet and numeric to determine if each character is valid.
Use the list registered to help you determine if the username is already registered.
Don't forget to execute the cell below to use these strings
# run this cell to create these variablesalphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'numeric = "0123456789"registered = ["john87", "topmage", "light4ever", "username2"]
Write a function nameValidation which receives a String argument name. This function:
has name String…
arrow_forward
Usernames
An online company needs your help to implement a program that verifies the username chosen by a new user. Their rules is described below:
Username MUST contain at least 6 characters;
Username cannot start with a number;
Username can only contain letters or numbers.
If valid, the username may be resgistered if it doesn't already exist in the system.
You should not use built-in functions to determine the character type such as isnumeric() or islower().
Use the strings given alphabet and numeric to determine if each character is valid.
Use the list registered to help you determine if the username is already registered.
Don't forget to execute the cell below to use these strings
# run this cell to create these variablesalphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'numeric = "0123456789"registered = ["john87", "topmage", "light4ever", "username2"]
arrow_forward
Usernames
An online company needs your help to implement a program that verifies the username chosen by a new user. Their rules is described below:
Username MUST contain at least 6 characters;
Username cannot start with a number;
Username can only contain letters or numbers.
If valid, the username may be resgistered if it doesn't already exist in the system.
You should not use built-in functions to determine the character type such as isnumeric() or islower().
Use the strings given alphabet and numeric to determine if each character is valid.
Use the list registered to help you determine if the username is already registered.
Don't forget to execute the cell below to use these strings
# run this cell to create these variablesalphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'numeric = "0123456789"registered = ["john87", "topmage", "light4ever", "username2"]
Write a function registerName which receives a String username and it returns a string message. This…
arrow_forward
Code in c++ please
arrow_forward
Packages and libraries functions Instructions: For this assignment, you need to create a program that allows the user to do some basic math functions. First, ask the user if they would like to find out sqrt, log or factorial of a number, and return the results.
Here is some sample output:
Welcome to the simple math helper.
Would you like to calculate?
1. Sqrt
2. Log
3. Factorial
> 1 Enter the number to sqrt:
> 9
3
Subject: Python Programming
arrow_forward
Flowchart, create.
#include<iostream>#include<string.h>using namespace std;// Write performOperation() function declaration heredouble performOperation(double numberOne, double numberTwo, string op);int main(){double numberOne, numberTwo;string operation;double result;cout << "Enter the first number: ";cin >> numberOne;cout << "Enter the second number: ";cin >> numberTwo;cout << "Enter an operator (+.-.*,/,%): ";cin >> operation;// Call performOperation method hereresult = performOperation(numberOne, numberTwo, operation);cout << numberOne;cout << " " << operation << " ";cout << numberTwo;cout << " = ";cout << result << endl;return 0;} // End of main() function// Write performOperation function heredouble performOperation(double numberOne, double numberTwo, std::string(op)){double result = 0.0;if (op == "+")result = numberOne + numberTwo;else if (op == "-")result = numberOne - numberTwo;else…
arrow_forward
Rectangle's Length and Width
Code in C language
// WARNING: Do not add, remove, or change anything before the line 19 of this file.// Doing so will nullify your score for the activity.
#include <stdio.h>#include "rectangle.h"
int get_length(Rectangle *rect);int get_width(Rectangle *rect);
int main() { int ur_x, ur_y, ll_x, ll_y; printf("UR's X: "); scanf("%d", &ur_x); printf("UR's Y: "); scanf("%d", &ur_y); printf("LL's X: "); scanf("%d", &ll_x); printf("LL's Y: "); scanf("%d", &ll_y); // TODO: Initialize the points here // Point ... // TODO: Initialize the rectangle here // Rectangle ... // TODO: Call the get_length here int len = ___; printf("\nLength: %d", len); // TODO: Call the get_width here int wid = ___; printf("\nWidth: %d", wid); return 0;}
// TODO implement get_lengthint get_length(Rectangle *rect) { return 0;}
// TODO implement get_widthint get_width(Rectangle *rect){ return 0;}
refer to pics for instructions
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Related Questions
- /* Program Name: BadDate.cpp Function: This program determines if a date entered by the user is valid. Input: Interactive Output: Valid date is printed or user is alerted that an invalid date was entered */ #include <iostream> bool validateDate(int, int, int); using namespace std; int main() { // Declare variables int year; int month; int day; const int MIN_YEAR = 0, MIN_MONTH = 1, MAX_MONTH = 12, MIN_DAY = 1, MAX_DAY = 31; bool validDate = true; // This is the work of the housekeeping() method // Get the year, then the month, then the day // This is the work of the detailLoop() method // Check to be sure date is valid if(year <= MIN_YEAR) // invalid year validDate = false; else if (month < MIN_MONTH || month > MAX_MONTH) // invalid month validDate = false; else if (day < MIN_DAY || day > MAX_DAY) // invalid day validDate = false; // This is the work of the endOfJob()…arrow_forwardNone [] # Don't write code in this line Q5: Complete the function that calculates the position of an object at any time t> 0. The initial position and the initial velocity (at time t=0) are denoted as so and v0 respectively. The object undergoes constant acceleration a, for any time t>0. [ ]: def calculate_position (s0,u,a,t): "given the initial conditions and acceleration, return the object's position. Use the variable named 'position' to hold and return this value """ # YOUR CODE HERE return position I ↑↓古早 Check your code here " Assign random input variables and check the answer"arrow_forwardOption #1: String Values in Reverse Order Assignment Instructions Write a Python function that will accept as input three string values from a user. The method will return to the user a concatenation of the string values in reverse order. The function is to be called from the main method. In the main method, prompt the user for the three strings.arrow_forward
- Functions and Optionals - How do I do this practice exercise using Swift code?arrow_forwardPROGRAMMING LANGUAGE: C++ TASK 1. You are required to create a simulation of an elevator system. There are 7 floors in a building. A user may enter the elevator and press the button of the destined floor. The simulation should display appropriate messages while moving towards the destined floor. Task 2. Write a program that takes +,-,*, and / operators and performs the required operation. the program will continue to execute until ESC key is pressed. Also, the usage of post-test loop and switch statement is mandatory.arrow_forward#include <stdio.h>#include <string.h> #pragma warning(disable : 4996) // compiler directive for Visual Studio only // Read before you start:// You are given a partially complete program. Complete the functions in order for this program to work successfully.// All instructions are given above the required functions, please read them and follow them carefully. // You shoud not modify the function return types or parameters.// You can assume that all inputs are valid. Ex: If prompted for an integer, the user will input an integer.// You can use only the strlen() of strings.h library to check string length. Do not use any other string functions // because you are supposed to use pointers for this homework. // **** DO NOT use arrays to store or to index the characters in the string **** // Global Macro Values. They are used to define the size of 2D array of characters#define NUM_STRINGS 4#define STRING_LENGTH 50 // Forward Declarationsvoid…arrow_forward
- 11 Worksheet 5 Note:Solution using Matlab Code Write a program that prompts the user to enter a number within the range of 1 through 7, those numbers represent the weekdays as shown in the table. If the entered number is more than 7, display 'invalid day'. Number 1 2 3 4 5 6 7 Day Sunday Monday Tuesday Wednesday Thursday Friday Saturday Type of the day Workday Workday Workday Workday Workday Weekend Weekend The program should continue to repeat itself 10 times, after which, the program should stop. Furthermore, the program should be able to show a message saying if this is a 'workday' or a 'weekend day'. Note: you are required to add a comment beside your command. Hint: to add a comment you may use the % sign. thank guys you dodo great.arrow_forwardPython get_user_input(message, sentinel): The parameter message is the string message to request an integer from the user. The parameter sentinel is the unique character that signals the end of input. This function will return value: done, The parameter done is a Boolean flag that signals that the user entered a sentinel value and the value is invalid. main(): calling the get_user_input function until the sentinel value is detected capture the output from the get_user_input function into two variables use the Boolean flag return value to control the loop in main store the integer return value to a Python list The program will print the integers entered back to the user only after the sentinel value is detectedarrow_forwardC++ beginnerarrow_forward
- please correct this code i didnt get the mistake #include<stdio.h>#define NROWS 8#define NCOLS 8#define TRUE 1#define FALSE 0 void main(){ int queenht_row, queenht_col; int line,row,col,i,j; int filled; printf("Chess queenht Program\n"); do{ printf("Enter queenht's coordinates: "); scanf("%d %d",&queenht_row,&queenht_col); }while((queenht_row<1)||(queenht_row>NROWS)||(queenht_col<1)||(queenht_col>NCOLS)); for(line=1;line<=2*NROWS+1;line++){ row = line/2; if(line%2!=0){ printf("+"); for(col=1;col<=NCOLS;col++) printf("---+"); printf("\n"); } else{ printf("|"); for(col=1;col<=NCOLS;col++){ filled=FALSE; if((row==queenht_row) && (col==queenht_col)){ printf(" Q |"); filled = TRUE; continue; }…arrow_forward#include <stdio.h>#include <stdlib.h> //declaring variables globally to calculate coinsint cent50 = 0;int cent20 = 0;int cent10 = 0;int cent05 = 0; //calculate change//pass change variable by addressvoid calculateChange(int* change) {//calculate change only if change is positiveif(*change > 0) {if(*change >= 50) {*change -= 50;cent50++;}else if(*change >= 20) {*change -= 20;cent20++;}else if(*change >= 10) {*change -= 10;cent10++;}else if(*change >= 05) {*change -= 05;cent05++;}//call calculateChange recursively calculateChange(change);}} // function to display the cents valuesvoid printChange() { if(cent50)printf("\n50 Cents : %d coins", cent50);if(cent20)printf("\n20 Cents : %d coins", cent20);if(cent10)printf("\n10 Cents : %d coins", cent10);if(cent05)printf("\n05 Cents : %d coins", cent05);//reset all cent variables with 0cent50 = 0;cent20 = 0;cent10 = 0;cent05 = 0; } //take change input from user//change variable passed addressvoid TakeChange(int*…arrow_forwardProgram Requirements This program should add numbers 1 through 9 one a time, via a button click, display the result, and allow the user to Clear the total to zero. Your Starter Codeworks for numbers 1 through 3. Give it a try, push the buttons, to see what it does. Extending Structured Programs is Easy In this assignment, you use existing code to: identify the patterns in a program modify the patterns in order to extend the functionality of the program Your Task for this Assignment Requirements: Extend this program to create the 6 more HTML buttons and 6 more Javascript functions. Software Development Best Practice: Incremental Development Do not program all your code at once like you were editing some essay. Making a big mess and then trying to patch it up all one once... is a nightmare. Add one button and its function Test it Repeat with the next button Pattern One: HTML Button Add your HTML code where the highlighted area is in the image below. Copy an existing button, and…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr