IMG_4366
.jpeg
keyboard_arrow_up
School
Southern New Hampshire University *
*We aren’t endorsed by this school
Course
X1977
Subject
Computer Science
Date
Apr 3, 2024
Type
jpeg
Pages
1
Uploaded by r1s23
B R RS T T PARTICIPATION £y < T Sy NS . i ACTIVITY 1.3.10: Converting user input to integers. 1} Type a statement that converts the string '15' to an integer and assigns the result to my_var. Answer my_var = int(15) 2 Input must be converted to an integer if using the inputn Show answer a calculation. 2} Complete the code so that new_var is equal to the entered number plus 5. Answer my var — oi{input()) 5+ my_var new_var = 7~ To perform addition int() must be used fo change the input string to an integer. Show answer
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
12. Which code segment results in "true" being returned if a number is even? Replace "MISSING CONDITION" with the
correct code segment.
function isEven(num){
if(MISSING CONDITION){
return true;
} else {
return false;
A. num % 2 == 0;
B. num % 0 == 2;
C. num % 1 == 0;
D. num % 1 == 2:
Powered by Linklt!
оо
arrow_forward
Programming Language: PHP
arrow_forward
.
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
5act2 Please help me code in python programming.
arrow_forward
C programring
arrow_forward
Question: 127 24
QUESTION
Which of the following statement(s) is/are invalid?
ANSWERS
float *p = new number[23];
int *p; p++;
int *P = new int; *P = 9;
a+b
dil
X
X
X
X
arrow_forward
C Language - Write a program that takes in three integers and outputs the largest value. If the input integers are the same, output the integers' value.
arrow_forward
/* 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
in C language
arrow_forward
Assignment
Write a program that tracks how much book pages the user reads in total in a day and reports if the
daily target is reached or not. The program will keep reading int values, each representing pages read
during an individual session within a day (pagesRead) until either the user enters 0 or the daily target
of 125 pages is met. If the user enters 0, the program should print the remaining pages to the daily
target as an int. Otherwise, the program should notify the user has reached the daily target by
printing the text "Target is reached in", followed by the number of sessions given as an int, and finally
printing the text " session(s)".
NOTE: You MUST use a repetitive statement in this question.
NOTE: Each pages Read value MAY also be given as a negative value. These values should simply be
skipped without affecting session count.
Input
40 20
Output
65
34 56 5 12 67
5.67-5 53
Target is reached in Target is reached in 3
5 session(s)
session(s)
arrow_forward
Language: Pyhon.
Processing: Mode 3.54 (Jonathan Feinberg)
Please post sketch fle code.
Create a sketch named boston pass. This program will tell the user whether they passed a course or not Please read the entire question before starting.
Create the following variables using an appropriate name and datatype (do not name them first variable, etc.)
First variable: keeps track of the student mark (whole number)
Second variable: keeps track of a Boolean value indicating if the student passed
Third variable: keeps track of amount the student passed or failed by (whole number)
Create the following functions using appropriate names (do not name them first function, etc.)
First function: accepts one numeric value, purpose is to see if a student passed the course (50 or more), returns a true or false value.
Second function: accepts one numeric value, purpose is to see how much more or less than 50 the student received, returns the amount higher or lower
than 50.
Third function: accepts one…
arrow_forward
>
Question 12
int x = 0;
int sum = 0;
for (x = 5; x < 5; x = x + 1)
{
}
cout << sum;
What is the value of sum printed?
O
O
O
sum sum + x;
0
N
arrow_forward
Compute: z = √x³ – [y]
Ex: If the input is 3.0 2.0, then the output is:
5.0
1 #include
2 #include
3 #include
4 using namespace std;
5
6 int main() {
double x;
667000
8
9
10
11
PEEEdda
cin >> X;
12 ctn >> y;
13
14 V* Your code goes here */
15
16 cout <<< fixed <<
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
X ، معلومات الدخول الى د
Quiz: FinalExam
quizzes/4585/take/questions/74430
Question 9
2 pts
What is the output of the following code? (NOTE: There are no
spaces between the output)
void test ()
{
static int x = 0;
int y = 1;
X = X + 2;
y =y + 13;
cout<
arrow_forward
PHP
ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but exactly 4
digits or exactly 6 digits.
*With user input ($pinNumbers), create a function that takes a string and returns true if the
PIN is valid and false if it's not.
Examples
validatePIN("$1234") ➞ true
validatePIN("12345") ➞ false
validatePIN("a234") ➞ false
validatePIN("") ➞ false
Notes
● Some test cases contain special characters.
● Empty strings must return false.
arrow_forward
O N "| L3%|
docs.google.com/forms/d/e/1l o
nסףש ןוחרורד
Computer
Programmingl
مطلوب
:Q1; Write a c++ program for the following
äbäi 15 A student will not be allowed to sit in
exam if his/her attendance is less
than 75%.Take following input from
user :Number of classes held,
Number of classes attended. And
print: percentage of class attended,
Is student is allowed to sit in exam or
.not
إجابتك
صفحة 2 من 3
التالي
رجوع
عدم إرسال كلمات المرور عبر نماذج Go ogle مطلقا.
تم إنشاء هذا النموذج داخل University. of Basrahالإبلاغ عن إساءة
الاستخدام
Google zilaj
II
arrow_forward
// declare and assign an int a value of 10
// declare and assign a double a value of 5.6
// declare and assign a boolean a value of true
3
4
5n
6.
7 }
C
arrow_forward
- What will be the value of M as a result of the following operations?
int M;
M=33/5;
cout<
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
def f(x: float) -> int:
return int(x)
def g(x: str) -> float:
return float(x)
y = f(g("3.14"))
Select all of the following statements that are true:
y's inferred data type is float
O y 's inferred data type is str
O y's inferred data type is int
There is a type error in this program
None of the above are true
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Related Questions
- 12. Which code segment results in "true" being returned if a number is even? Replace "MISSING CONDITION" with the correct code segment. function isEven(num){ if(MISSING CONDITION){ return true; } else { return false; A. num % 2 == 0; B. num % 0 == 2; C. num % 1 == 0; D. num % 1 == 2: Powered by Linklt! ооarrow_forwardProgramming Language: PHParrow_forward.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_forward5act2 Please help me code in python programming.arrow_forwardC programringarrow_forward
- Question: 127 24 QUESTION Which of the following statement(s) is/are invalid? ANSWERS float *p = new number[23]; int *p; p++; int *P = new int; *P = 9; a+b dil X X X Xarrow_forwardC Language - Write a program that takes in three integers and outputs the largest value. If the input integers are the same, output the integers' value.arrow_forward/* 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
- in C languagearrow_forwardAssignment Write a program that tracks how much book pages the user reads in total in a day and reports if the daily target is reached or not. The program will keep reading int values, each representing pages read during an individual session within a day (pagesRead) until either the user enters 0 or the daily target of 125 pages is met. If the user enters 0, the program should print the remaining pages to the daily target as an int. Otherwise, the program should notify the user has reached the daily target by printing the text "Target is reached in", followed by the number of sessions given as an int, and finally printing the text " session(s)". NOTE: You MUST use a repetitive statement in this question. NOTE: Each pages Read value MAY also be given as a negative value. These values should simply be skipped without affecting session count. Input 40 20 Output 65 34 56 5 12 67 5.67-5 53 Target is reached in Target is reached in 3 5 session(s) session(s)arrow_forwardLanguage: Pyhon. Processing: Mode 3.54 (Jonathan Feinberg) Please post sketch fle code. Create a sketch named boston pass. This program will tell the user whether they passed a course or not Please read the entire question before starting. Create the following variables using an appropriate name and datatype (do not name them first variable, etc.) First variable: keeps track of the student mark (whole number) Second variable: keeps track of a Boolean value indicating if the student passed Third variable: keeps track of amount the student passed or failed by (whole number) Create the following functions using appropriate names (do not name them first function, etc.) First function: accepts one numeric value, purpose is to see if a student passed the course (50 or more), returns a true or false value. Second function: accepts one numeric value, purpose is to see how much more or less than 50 the student received, returns the amount higher or lower than 50. Third function: accepts one…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr