Computer Science: An Overview (13th Edition) (What's New in Computer Science)
13th Edition
ISBN: 9780134875460
Author: Glenn Brookshear, Dennis Brylow
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 5, Problem 31CRP
Program Plan Intro
Count is used as a conditional variable. It is used inside the ‘while loop’ and iteration takes place until the condition fails.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program that takes a **string** as input and outputs “Binary Number” if the string contains only 0s or 1s. Otherwise, outputs “Not a Binary Number”.
===================================================================== **Sample Input 1:**\01101101101
**Sample Output 1:**\Binary Number
=====================================================================
**Sample Input 2:**\12344ab0
**Sample Output 2:**\Not a Binary Number
=====================================================================
**Sample Input 3:**\10127490111
**Sample Output 3:**\Not a Binary Number
=====================================================================
**Sample Input 4:**\Binary Number
**Sample Output 4:**\Not a Binary Number
#todo#assign the result string to variable "out_str"def task3(in_str): # YOUR CODE HERE return out_str
I need help in tracing the following program step by step.
int foo1(int *A, int *B, int C) {int temp;temp = *A + C;*A = *B + C;*B = C + C;return temp;};int main(){int A = 1, B = 2, C = 3;C = foo1(&A, &B, C);B = foo1(&B, &C, A);A = foo1(&C, &A, B);printf("%d%d%d", A, B, C);return 0;}
I have a difficult task that i have been given, the problem is that I just simply cant seem to manage to first print a binary number so if you give me six my code doesnt seem to print the number in binary. but also i need to print it in reverse and my code just doesnt seem to work with that.
heres my code
import java.util.Scanner;
public class LabProgram { public static void main(String[] args) { int x; int output; int i; Scanner input = new Scanner(System.in); x = input.nextInt(); output = x; for ( i = 0; i <= x; i = ++i){ output = x / 2; System.out.println(output); } } }
// and bellow this are my instructions . what am i doing wrong what am i missing? ive googled sites and erased portions of code, put in eithers. ive switched back and forth from a for loop to a while loop for awhile now
Write a program that takes in a positive integer as input, and…
Chapter 5 Solutions
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Ch. 5.1 - Prob. 1QECh. 5.1 - Prob. 2QECh. 5.1 - Prob. 3QECh. 5.1 - Suppose the insertion sort as presented in Figure...Ch. 5.2 - A primitive in one context might turn out to be a...Ch. 5.2 - Prob. 2QECh. 5.2 - The Euclidean algorithm finds the greatest common...Ch. 5.2 - Describe a collection of primitives that are used...Ch. 5.3 - Prob. 2QECh. 5.3 - Prob. 3QE
Ch. 5.3 - Prob. 4QECh. 5.4 - Modify the sequential search function in Figure...Ch. 5.4 - Prob. 2QECh. 5.4 - Some of the popular programming languages today...Ch. 5.4 - Suppose the insertion sort as presented in Figure...Ch. 5.4 - Prob. 5QECh. 5.4 - Prob. 6QECh. 5.4 - Prob. 7QECh. 5.5 - What names are interrogated by the binary search...Ch. 5.5 - Prob. 2QECh. 5.5 - What sequence of numbers would be printed by the...Ch. 5.5 - What is the termination condition in the recursive...Ch. 5.6 - Prob. 1QECh. 5.6 - Give an example of an algorithm in each of the...Ch. 5.6 - List the classes (n2), (log2n), (n), and (n3) in...Ch. 5.6 - Prob. 4QECh. 5.6 - Prob. 5QECh. 5.6 - Prob. 6QECh. 5.6 - Prob. 7QECh. 5.6 - Suppose that both a program and the hardware that...Ch. 5 - Prob. 1CRPCh. 5 - Prob. 2CRPCh. 5 - Prob. 3CRPCh. 5 - Select a subject with which you are familiar and...Ch. 5 - Does the following program represent an algorithm...Ch. 5 - Prob. 6CRPCh. 5 - Prob. 7CRPCh. 5 - Prob. 8CRPCh. 5 - What must be done to translate a posttest loop...Ch. 5 - Design an algorithm that when given an arrangement...Ch. 5 - Prob. 11CRPCh. 5 - Design an algorithm for determining the day of the...Ch. 5 - What is the difference between a formal...Ch. 5 - Prob. 14CRPCh. 5 - Prob. 15CRPCh. 5 - The following is a multiplication problem in...Ch. 5 - Prob. 17CRPCh. 5 - Four prospectors with only one lantern must walk...Ch. 5 - Starting with a large wine glass and a small wine...Ch. 5 - Two bees, named Romeo and Juliet, live in...Ch. 5 - What letters are interrogated by the binary search...Ch. 5 - The following algorithm is designed to print the...Ch. 5 - What sequence of numbers is printed by the...Ch. 5 - Prob. 24CRPCh. 5 - What letters are interrogated by the binary search...Ch. 5 - Prob. 26CRPCh. 5 - Identity the termination condition in each of the...Ch. 5 - Identity the body of the following loop structure...Ch. 5 - Prob. 29CRPCh. 5 - Design a recursive version of the Euclidean...Ch. 5 - Prob. 31CRPCh. 5 - Identify the important constituents of the control...Ch. 5 - Identify the termination condition in the...Ch. 5 - Call the function MysteryPrint (defined below)...Ch. 5 - Prob. 35CRPCh. 5 - Prob. 36CRPCh. 5 - Prob. 37CRPCh. 5 - The factorial of 0 is defined to be 1. The...Ch. 5 - a. Suppose you must sort a list of five names, and...Ch. 5 - The puzzle called the Towers of Hanoi consists of...Ch. 5 - Prob. 41CRPCh. 5 - Develop two algorithms, one based on a loop...Ch. 5 - Design an algorithm to find the square root of a...Ch. 5 - Prob. 44CRPCh. 5 - Prob. 45CRPCh. 5 - Design an algorithm that, given a list of five or...Ch. 5 - Prob. 47CRPCh. 5 - Prob. 48CRPCh. 5 - Prob. 49CRPCh. 5 - Prob. 50CRPCh. 5 - Prob. 51CRPCh. 5 - Does the loop in the following routine terminate?...Ch. 5 - Prob. 53CRPCh. 5 - Prob. 54CRPCh. 5 - The following program segment is designed to find...Ch. 5 - a. Identity the preconditions for the sequential...Ch. 5 - Prob. 57CRPCh. 5 - Prob. 1SICh. 5 - Prob. 2SICh. 5 - Prob. 3SICh. 5 - Prob. 4SICh. 5 - Prob. 5SICh. 5 - Is it ethical to design an algorithm for...Ch. 5 - Prob. 7SICh. 5 - Prob. 8SI
Knowledge Booster
Similar questions
- In python, write a program that receives an integer from the user, called n, and prints the first n prime numbers. For example, if the input is 7, the output should be: 2, 3, 5, 7, 11, 13, 17.arrow_forward1- Write a program that can calculate the class average for a number of students. The user should be able to enter the grades, use sentinel-controlled repetition to manage input. (python) Sample Output: Enter grade, -1 to end: 75 Enter grade, -1 to end: 94 Enter grade, -1 to end: 97 Enter grade, -1 to end: 88 Enter grade, -1 to end: 70 Enter grade, -1 to end: 64 Enter grade, -1 to end: 83 Enter grade, -1 to end: 89 Enter grade, -1 to end: -1 class average is 82.5 2- Write a program that reads in two integers and determines and prints whether the first is a multiple of the second. (Hint: Use the modulus operator.arrow_forwardWrite the output for the given source code , if compiled:Given that y = ax3 + 7String s1 = "hello there"; char[] charArray = new char[ 5 ]; System.out.printf( "s1: %s", s1 ); // test length method System.out.printf( "\nLength of s1: %d", ); // loop through characters in s1 with charAt and display reversed System.out.print( "\nThe string reversed is: " ); for ( int count = s1.length() - 1; count >= 0; count-- ) System.out.printf( "%c ", ); System.out.print( "\nThe character array is: " ); for ( char character : charArray ) System.out.print( character ); System.out.println(); , which of the following are correct Java statements for this equation?arrow_forward
- The Question is for a python class asking to add a loop Starting with the following code, add a loop that will prompt the user for the number of math questions the user would like to be presented with: import random firstnum = random.randrange(1,11) # return an int from 1 to 10 secondnum = random.randrange(1, 11) compsum = firstnum + secondnum # adds the 2 random numbers together # print (compsum) # print for troubleshooting print("What is the sum of", firstnum, " +", secondnum, "?") # presents problem to user added = int(input("Your answer is: ")) # gets user input if added == compsum: # compares user input to real answer print("You are correct!!!") else: print ("Sorry, you are incorrect")arrow_forward### Exercise in Python1 ###\n", "\n", "Open the text oneArt.txt, read the text line by line and, at the end, print the number of lines of text that are in the file. Do not count blank lines."arrow_forwardImplement a program that prompts the user to enter two positive numbers as formatted below Enter num1: Enter num2: Input validation MUST be completed input must be all digits input must be a positive number, Integer Overflow for the individual inputs and the sum of the inputs is now VALID and needs to be handled as described below with the ADDITION ALGORITHM. If NOT valid (non-digits or negative) then re-prompt as formatted below INVALID RE-Enter num 3 incorrect inputs in a row and stop program. This is the 3 strikes and you're out rule. PROGRAM ABORT ADDITION ALGORITH The input CANNOT be converted to a true int, unsigned int, long, unsigned long or long long data type The solution is to use an array to store each individual digit of the number For example, the inputted number: "1234" could be stored in the array nums backwards, so the ones position is at index 0 of the array. 4 = 10^0 (ones position) so that nums[0] = 4 3 =…arrow_forward
- Implement a program that prompts the user to enter two positive numbers as formatted below Enter num1: Enter num2: Input validation MUST be completed input must be all digits input must be a positive number, Integer Overflow for the individual inputs and the sum of the inputs is now VALID and needs to be handled as described below with the ADDITION ALGORITHM. If NOT valid (non-digits or negative) then re-prompt as formatted below INVALID RE-Enter num 3 incorrect inputs in a row and stop program. This is the 3 strikes and you're out rule. PROGRAM ABORT ADDITION ALGORITH The input CANNOT be converted to a true int, unsigned int, long, unsigned long or long long data type The solution is to use an array to store each individual digit of the number For example, the inputted number: "1234" could be stored in the array nums backwards, so the ones position is at index 0 of the array. 4 = 10^0 (ones position) so that nums[0] = 4 3 = 10^1 (tens position) so that nums[1] = 3 2 = 10^2 (hundreds…arrow_forwardA twin is somewhat a pair of things that look exactly the same, whether in uppercase or lowercase form. And you know what? They exist in strings, too! Input Format Two lines containing a string on each. Input Sample cup CUp Output Format A line containing a string. Output Sample Equal Another Test Sample: Input Sample nIce N1ce Output Sample Not Equal Note: In C programming, using array without using strcmp/strcmpi and pointers. Make the code simple as much as possible. Thank you!arrow_forwardIn Python: What gets printed by executing the following code? def teststrings():str1 = 'X University'str2 = 'Computer Science'print(str1[0].isupper()) #str3 = str1.replace("university',' ')str2+=' ' +str1print(str1)print(str3.rstrip())print(str2)def main():teststrings()main()arrow_forward
- can you help me implement the clock class in java to measure how fast the input reading and outputting it to a file takes me? I don't know where to startarrow_forwardHow do I program this output using python? Here is my starting code. Please do help me fix this. Thank you so much. -----------------The code---------------- def SPACES_COUNTER (name): name counter_len = 0 name_len = [] while (counter_len < len(name)): for i in range (counter_len): name_len.append(len(name[i])) counter_len += 1 return max(name_len) stud_id = []name = []address = []age = [] num_of_records = int(input("Enter number of records: "))counter=0while (counter< num_of_records): for i in range(num_of_records): stud_id_input = input("Enter Student ID: ") stud_id.append(stud_id_input) name_input = input('Enter Name: ') name.append(name_input) address_input = input('Enter address: ') address.append(address_input) age_input = int(input("Enter Age: ")) age.append(age_input) counter += 1 name_spaces = SPACES_COUNTER(name)student_spaces =…arrow_forwardWrite a program that takes in an integer in the range 20-98 as input. The output is a countdown starting from the integer, and stopping when both output digits are identical. Ex: If the input is 93, the output is: 93 92 91 90 89 88 Ex: If the input is 77, the output is: 77 Ex: If the input is not between 20 and 98 (inclusive), the output is: Input must be 20-98 For coding simplicity, follow each output number by a space, even the last one. Use a while loop. Compare the digits; do not write a large if-else for all possible same-digit numbers (11, 22, 33, ..., 88), as that approach would be cumbersome for large ranges.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education