Questions tagged [sentinel]

A sentinel is a loop exit value or list delimiter whose value is outside the range of valid input, such as -1 for a zero-based array index, or ~ for alphabetic strings.

410 questions
-1
votes
2 answers

How can I understand loops and also how to get them to work properly

I am trying to understand how loops work but I can't seem to piece it together. I am working on a shipping java program and whatever I try will not work. So far I have when the integers are correct it proceeds with the program, but I want it when I…
Xela
  • 3
  • 2
-1
votes
6 answers

A C++ program that gets 100 integers and finds the possibly given negative ones

I'm trying to write the code for a C++ program which will get some numbers (integers) and will put them into a 100 sized array, and will begin searching for possibly given negative ones (Negative of given positive numbers) after the user had…
Sepehr Student
  • 23
  • 1
  • 1
  • 6
-1
votes
2 answers

test for data type errors in loops java

Yes, this is a homework problem. I am a beginner in programming. I am good at using if/else with for loops, since my professor asked us to while loop. I am confused.This is the question... Q1) Suppose you are writing a game-playing program that…
happy face
  • 43
  • 9
-1
votes
4 answers

Python: Loop Sentinel Value

I'm supposed to write a program with a loop that lets the user enter a series of integers, followed by -99 to signal the end of the series. After all the numbers have been entered, the program should display the largest and smallest numbers…
Cesco
  • 3
  • 1
  • 1
  • 2
-1
votes
2 answers

Repeating the whole program and assigning a sentinel value

I would really appreciate some help on this problem; I am also very new to Java, so please excuse any misuse of terms/any other probably clear signs of confusion. This is for a class I'm taking. I have looked this up extensively but have gotten no…
user3892007
-2
votes
1 answer

How to differentiate code terminology in MEDICAL SERVICE LINES?

In the MEDICAL_SERVICE_LINES table, there is a field ‘PROCEDURE’. The data dictionary notes that this is ‘CPT, HCPCS, or ICD-10-PCS (less commonly)’. Is there a field that indicates which of these terminologies the code is from? Can you use…
-2
votes
3 answers

How to merge two arrays without duplicates?

I am a beginner. I think the main issue I have is with flags. (I cannot use a break command to stop the loops). Ex: A={1,2,3,4,5} B={1,2,3,6} I have to generate a new array with the previous ones, without duplicates. So: C={1,2,3,4,5,6}. #include…
Yaron Pray
  • 13
  • 1
  • 3
-2
votes
1 answer

What is the correct initialization of a variable and subsequent order of a function in a sentinel-controlled loop?

I am new to C++, I wrote this code for practice and can't seem to understand why my code still loops after I input the sentinel value. Sample output: Please enter your sales amount or -1 to exit: 25100 Your salary for the month is:$31110.00 Please…
-2
votes
1 answer

how can i access the current logged in user using Sentinel with laravel api

i created a login system with Laravel & sentinel. after that i just test api in Laravel with this code to obtain some data about the current logged in user using this code in api.php. but i had an error message when i test it " The use statement…
Ahmed Masry
  • 17
  • 1
  • 6
-2
votes
1 answer

How do I add a sentinel value to my code?

When the user enters 0, the program is supposed to stop. I can't figure out how to do this. For example: Enter the integers between 1 and 100: 2 5 6 5 4 3 23 43 2 0 2 occurs 2 times 3 occurs 1 time 4 occurs 1 time 5 occurs 2 times 6 occurs 1…
-2
votes
2 answers

Program doesn't exit when I hit n or N?

I have the following homework problem: Q1. Use nested for loops statements to draw empty boxes of any character (input from user). The boxes have the same number of rows and columns (input from the user; valid range: 5 to 21). Test for errors in…
happy face
  • 43
  • 9
-2
votes
3 answers

string array loop print value null java

I have instantiated a String array containing 10 strings. I basically want to ask the user to enter a subject name until all 10 strings are finished, or if the user enters "q" to quit. Once this happens, the String array elements should be printed…
Bob
  • 39
  • 1
  • 8
-2
votes
1 answer

How to put sentinel in for loop

I have a couple of issues that i need to fix.This program finds the average of a number desired by the user.For example if they put in 3 and then 1,2,3 then the average is 2. First of all my program is supposed to stop if zero is inputed. so if i…
jimm bo
  • 3
  • 4
-3
votes
2 answers

Trying to end a while loop once a 1 is randomly generated or it loops 10 times

(I apologize for the atrocious formatting) I am attempting to make a random number generator (min = 1, max = 10) that loops until either a) a 1 is generated (serve as primary sentinel). b) loop iterates 10 times (secondary sentinel) without…
-3
votes
1 answer

How can i create a program that asks for input of index of 2d array and outputs the value at that index?

Write a program, that allows a user to input integer values and query a 2-dimensional array of size 9x9. Your program should then ask the user for a pair of coordinates,(x,y), separated by a space and return the value at the position specified by…
1 2 3
27
28