homework

How can I process several inputs at once using cin or getline(), while only pressing "Enter" once?

nodeType* buildSet() { nodeType *first, *newNode, *last; first = NULL; int num = 0; string input = ""; getline(cin,input); stringstream myStream(input); while(myStream >> num) // while(num != -999) { newNode = new nodeType; newNode->info = num; newNode->link = NULL; if(first ...

Removing and adding nodes to a tree

I have an assignment, and I can't figure out what to do about it. I have a tree of people with their name, birth and death year. Think genealogy here. I have a bunch of datatypes to take care of ages, names, the tree itself, etc. and then I have a bunch of people and a tree. The datatypes are: datatype year = Year of int | UnkYear |...

I have a homework assignement about arraylist

I have a homework assignemnt that I have been working with for the past few days and I just keep on going circles and circles thinking that I got the codes right but something wrong always comes up. These are the requirments In assignment 2, you will use the modified solution of the assignment 1. In the current version, the database is...

I'm stuck on my homework, can I get some feedback? java

package javaapplication1; public class Main { public static void main(String[] args) { Student stu = new Student(); System.out.println (stu.getStudentid() +":" + stu.getStudentname()+":"+stu.getStudentgrade()); //1:Bill:A Student stu2 = new Student (); System.out.println (stu2.getStuden...

Creating new system calls via KLD in FreeBSD

Are there any good (entry-level) tutorials on adding system calls to FreeBSD via kernel loadable modules? Specifically, the required form of the methods, getting information from processes, etc. ...

Need help with UML Class Diagram and Pseudocode

Okay this is my Homework assignment The Pizza With Pizzazz Pizza Parlor sells nothing but pizza. Design an object-oriented computer program by doing the following: a. Create the class diagram and pseudocode for the Pizza service class that contains the toppings for the pizza, the size of the pizza in inches, and the price of the pizza....

Why am I getting a segmentation fault?

Hey guys I'm trying to write a program that takes in a plaintext file as it's argument and parses through it, adding all the numbers together and then print out the sum. The following is my code: #include <stdio.h> #include <stdlib.h> #include <ctype.h> static int sumNumbers(char filename[]) { int sum = 0; FILE *file = fopen(fi...

Help with simple Hotel check-in system

For my CS course I have to program a hotel checkin/checkout system. The program must be able to check people in and out. The programm assigns the first available room to a guest upon checkin. If no room is free, it will say so as well. The Hotel has four rooms. In the assignment it says there need to be 4 classes: Assignment5, Hotel, R...

C exit function not doing what I thought it would

When I use a debugger I can tell the exit is not exiting the function. Am I using the exit function wrong? (i must be) how do I fix this? int is_prime(int x,char array[]){ int divider = (x-1); float test; while(x>-1){ test = isdigit((x % divider)); //isdigit returns !0 if digit if(divider == '1'){ return(1); //if divi...

How to make different instances of a class?

I am making a simple programm that allows people to checkin and out a hotel (for my CS class). What I need to be able to do is check in a person in a room. There are four rooms. How can i make it so that when someone is checked in, the next person that checks in will check in room 2. i have the following already: class Hotel { ...

I have added this but I keep getting errors.

I have added this as my arraylist and under my inventory list I keep getting errors. What am I doing wrong. import java.util.Arrays; public class MyArrayList { String[] strings = new String[2]; int size = 0; public void add(String str) { if (size == strings.length) { // Double the size strings = Arrays.copy...

Appending a string to an array

I have to write a function that prepends if boolean is true or append if boolean is false a string to an array. I'm not exactly sure what this means? Do I just add a string to the first element of the array if I'm prepending or add a string to the last element of the array if I'm appending? Or what? ...

Problem Implementing Function With Existing Class Design

I've currently started on my semester project for my programming course- programming a fully autonomous driving simulator. All cars are steered through AI and the map is printed in the console. The first sheet wants us to create a couple of basic classes: FCCompact (The car), Scanner (AI), ID (terrain), and World (The map). The Scann...

Adding a node to a tree in SML

I was advised to ask this as a separate question, so that I will do. I have a tree of people, like in genealogy. It starts with a person and branches off into parents, grandparents, etc. I want to be able to insert a person into a spot on the tree (basically replacing whoever is there). These datatypes are important: datatype year ...

Splitting Arrays- is my implementation correct?

I'm writing code for a hybrid data structure for school, and am debugging the code. Basically, this structure is a combination of a Double Linked List and an Array, where each list node contains an array of set size. Since this is an ordered structure, a provision has to be made to identify and split full arrays into equally into two n...

Comparing diferent algorithms

I get the following errors for this code: Error 1 : In function `_Function std::for_each(_InputIterator, _InputIterator, _Function) [with _InputIterator = std::_List_iterator, _Function = void (*)(int)]': Error 2 line 16 with the bool. int main(int argc,char *argv[]) { if (argc != 4) { cout << "Error input!"; ...

Java Resizing an Array

I want to write a function that resizes a 2D array to the given parameters. Its a general resize array: public static int[][] resize(int[][] source, int newWidth, int newHeight) { int[][] newImage=new int[newWidth][newHeight]; double scale=newWidth/source.length; for (int j=0;j<newHeight;j++) for (in...

MYSQL -populating the database

How do we populate the data into mySql windows 5.1. version?I have .csv files. I'm not allowed to use the load data command. Please help me out. ...

How to tell whether a red-black tree can have X black nodes and Y red nodes or not

Hello everyone, I have an exam next week in algorithms, and was given questions to prepare for it. One of these questions has me stumped though. "Can we draw a red-black tree with 7 black nodes and 10 red nodes? why?" It sounds like it could be answered quickly, but I can't get my mind around it. The CRLS gives us the maximum height ...

Write regular expression for C numerical literals

My homework is to write a regular expression representing the language of numerical literals from C programming language. I can use l for letter, d for digit, a for +, m for -, and p for point. Assume that there are no limits on the number of consecutive digits in any part of the expression. Some of the examples of valid numerical liter...