Member Avatar

I am trying to generate a program using the builtin Random and generate an algorithm that determines whether the number is odd or even. I need to write a program that generates 100 random numbers, determine if its even or odd and finally count the number of even and odd. I am new to Python. This is what I have thus far, but nothin is working. Could someone give me a push in the right direction?? Thank you so much. import random def main(): # explain program intro() # get a random number number = random.randint(1,100) # generate Boonlean variables …

Member Avatar
+0 forum 8
Member Avatar

Upon playing with the graphics/random class - I have discovered something odd. Private Sub Me_Load(sender As Object, e As EventArgs) Handles Me.Load For i = 0 To 5000 DrawColor(GimmiRectangle) Next End Sub Private Sub DrawColor(ByVal rNew As Rectangle) Try Dim g As Graphics = Me.CreateGraphics g.DrawRectangle(New Pen(Color.FromArgb(New Random().Next(255), New Random().Next(255), New Random().Next(255))), rNew) Catch ex As Exception MsgBox(ex.ToString) End Try End Sub Private Function GimmiRectangle() As Rectangle Try Dim rect As New Rectangle(New Random().Next(1000), New Random().Next(1000), New Random().Next(1000), New Random().Next(1000)) Return rect Catch ex As Exception MsgBox(ex.ToString) Return New Rectangle(0, 0, 0, 0) End Try End Function This code will …

Member Avatar
+0 forum 2
Member Avatar

I used `memcpy` to copy the contents of one pointer to another pointer assigned to new memory. Later in the program I get runtime errors as if I were attempting to operate on a pointer pointing to nothing. While debugging, I saw that the original and the the copied pointer had different addresses but they acted as if they were one, for example If I set a property of the copied pointer to 'a' the original would also get set to 'a'. In this case I delete the copied pointer and the original gets deleted too as if they pointed …

Member Avatar
+0 forum 4
Member Avatar

Im having this weird runtime error whenever I attempt to copy a specific member of an array block. I get this from the output: ASSERT failure in QHash: "Iterating beyond end()", file tools/qhash.cpp, line 293 Invalid parameter passed to C runtime function. Invalid parameter passed to C runtime function. I redid the code so i could specify what seems to be causing the problem. //"Heading" is a QString someClass *pointerFromArrayBlock = &theArray[10]; cout<< pointerFromArrayBlock->Heading() <<endl;//runs fine QString test = pointerFromArrayBlock->Heading();//causes crash someClass *pointer_NOT_FromArray = new someClass(/*some parameters*/); cout<< value_NOT_FromArray->Heading() <<endl;//runs fine QString test2 = value_NOT_FromArray->Heading(); //runs fine

Member Avatar
+0 forum 8
Member Avatar

I need to design an application that determines and prints the number of odd, even, and zero digits in an integer value read from the keyboard. This is what I have so far. public static void main (String[] args) { int odd=0, even=0, zero=0; Scanner scan = new Scanner(System.in); int num = scan.nextInt(); String numS = Integer.toString(num); int digits = numS.length(); for (int i = 0; i < digits; i++) { if (numS.indexOf(i) == 0) { zero++; } else if (numS.indexOf(i) % 2 == 0) { even++; } else { odd++; } } System.out.println("The number of odd digits are: " …

Member Avatar
+0 forum 3
Member Avatar

Just in the news: A Miami police officer fatally shot a naked man who refused to stop chewing on the face of another naked man — even after being shot once by the officer — on a busy downtown highway ramp. Have you read any other strange news lately?

Member Avatar
+0 forum 3
Member Avatar

HI, I'm writing a code for the very first time, and I'm completely stuck. Some guidance would be great. I'm writing a C program that reads integars from file "integars.dat". The program should show how many numbers you have entered, how many among them were even, and how many were odd. Also the average of integer numbers that were odd. It should be done using nested loops, ifs whiles fors, as its a beginners program. It does read in the integars from the FILE, and counts them properly , except it doesnt count the odd and even integars. [CODE]#include <stdio.h> …

Member Avatar
+0 forum 6
Member Avatar

Hi i am just new to VB.NET and our teacher told us to experiment on for loop in a ODD SUM Program you need to add all odd numbers from Input One to Input Two like that but i can't stop it from adding continuously for example i input the first number 1 and the second 10 if i click the button one time the output should be 25 but when i click again the button it becomes 50 its wrong i can't terminate the process help me [CODE] Dim oddOne As Integer Dim oddTwo As Integer oddTwo = Val(txtInputTwo.Text) …

Member Avatar
+0 forum 1
Member Avatar

In this program i am trying to find numbers that are multiples of 7,11, or 13, also if the total of the numbers is even or odd also the square root value of each number also if there are any prime numbers in the list [CODE]#include<iostream> #include<iomanip> #include<fstream> #include<cmath> #include<conio.h> // Associating program identifiers with external file names #define in_file "data.txt"//input file name #define out_file "result.txt"//output file name using namespace std; void multiple(int); void even_odd(int); void square_root(double); void prime(int); int temp_a; double temp_c; int total; int num; ifstream ins;// associates ins as an input stream ofstream outs;// associates outs as …

Member Avatar
+0 forum 5

The End.