Search Results

Search found 1523 results on 61 pages for 'assignment'.

Page 3/61 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Compound assignment operators in Python's Numpy library

    - by Leonard
    The "vectorizing" of fancy indexing by Python's numpy library sometimes gives unexpected results. For example: import numpy a = numpy.zeros((1000,4), dtype='uint32') b = numpy.zeros((1000,4), dtype='uint32') i = numpy.random.random_integers(0,999,1000) j = numpy.random.random_integers(0,3,1000) a[i,j] += 1 for k in xrange(1000): b[i[k],j[k]] += 1 Gives different results in the arrays 'a' and 'b' (i.e. the appearance of tuple (i,j) appears as 1 in 'a' regardless of repeats, whereas repeats are counted in 'b'). This is easily verified as follows: numpy.sum(a) 883 numpy.sum(b) 1000 It is also notable that the fancy indexing version is almost two orders of magnitude faster than the for loop. My question is: "Is there an efficient way for numpy to compute the repeat counts as implemented using the for loop in the provided example?"

    Read the article

  • Assignment of roles in communication when sides could try to cheat

    - by 9000
    Assume two nodes in a peer-to-peer network initiating a communication. In this communication, one node has to serve as a "sender", another as a "receiver" (role names are arbitrary here). I'd like the nodes to assert either role with approximately equal probability. That is, in N communications with various other nodes a given node would assume the "sender" role roughly N/2 times. Since there's no third-party arbiter available, nodes should agree on their roles by exchanging messages. The catch is that we can encounter a rogue node which would try to become the "receiver" in most or all cases, and coax the other side to always serve as a "sender". I'm looking for an algorithm to assign roles to sides of communication so that no side could get a predetermined role with high probability. It's OK for the side which is trying to cheat to fail to communicate.

    Read the article

  • license and copyright assignment

    - by corintiumrope
    I'm currently working on a wordpress plugin. My client gives me a specs doc (a powerpoint presentation, if you can call that a specs doc), and I code the requested functionality. Every time I send him code every file containing code starts with these lines: Author: My Name Copyright: The_client's_company.com License: MIT Expat (http://en.wikipedia.org/wiki/Expat_License) My intention being giving my client complete right to relicense and distribute the code under any other license (as the TOS of the freelancing website requires, plus I know he intends to sell it under a proprietary license), but at the same time giving myself the right to expand and redistribute the plugin under MIT license if I wish to (not that I do). The reason is I am paid only 10USD/hour (this is my first gig) so I want to at least keep the right to reuse parts of the code in other projects or expand it if I want to start a similar project myself when I finish the contract (unlikely, but who knows...) or show it to potential employees. The contract we agreed upon doesn't include any licensing specifications but I've informed him on the emails we've interchanged that although all my work is licensed by default as MIT I'm giving my clients the copyright of the code I produce so they can relicense it at will before distribution. Is this the correct way of achieving that?

    Read the article

  • Algorithms for pairing a rating system to an assignment queue

    - by blunders
    Attempting to research how to allow a group of people to effectively rank a set of objects (each group member will have contributed one object to the group), and then assign each member an object that's not their own based on: Their ratings of the objects, Their objects rating, and The object remaining to be assigned. Idea is to attempt to assign objects to people based on the groups rating of their contribution to the group relative to other member's contribution, the the personal preferences expressed via the ratings. Any suggestions for: Further research, Refining the statement of the problem/solution, or A solution.

    Read the article

  • Parallel Assignment operator in Ruby

    - by Bragaadeesh
    Hi, I was going through an example from Programming in Ruby book. This is that example def fib_up_to(max) i1, i2 = 1, 1 # parallel assignment (i1 = 1 and i2 = 1) while i1 <= max yield i1 i1, i2 = i2, i1+i2 end end fib_up_to(100) {|f| print f, " " } The above program simply prints the fibonacci numbers upto 100. Thats fine. My question here is when i replace the parallel assignment with something like this, i1 = i2 i2 = i1+i2 I am not getting the desired output. My question here is, is it advisable to use parallel assignments? (I come from Java background and it feels really wierd to see this type of assignment) One more doubt is : Is parallel assignment an operator?? Thanks

    Read the article

  • Creating nested fields for column on assignment table?

    - by H O
    I have three models, that represent a many to many relationship - Product, Sale and Product_sale. I have a nested form that allows me to create new products from the sale form - so far, so good. I have, however, added some additional fields to the assignment table - price, for example. How can I set the price on the assignment table from the product form, when it is nested in the sale form? I currently have the code below: <%= sale.fields_for :products do |products_builder| %> <%= render :partial => "products/form", :locals => {:f => products_builder, :form_actions_visible => false} %> <% end -%> I could nest a Product_sale form within the product form, but this would create a new product_sale, which is not what I am looking for. I will most likely need to nest the price field within the product form, to ensure that it updates the correct assignment record (since there could be multiple products on one sale form). How can I use a fields_for loop on the product form to update the existing assignment record that is built when I do @sale.products.build? The assignment record will not yet be saved, so I can not access it using a where clause and edit it that way. Thanks!

    Read the article

  • Using a class with const data members in a vector

    - by Max
    Given a class like this: class Foo { const int a; }; Is it possible to put that class in a vector? When I try, my compiler tells me it can't use the default assignment operator. I try to write my own, but googling around tells me that it's impossible to write an assignment operator for a class with const data members. One post I found said that "if you made [the data member] const that means you don't want assignment to happen in the first place." This makes sense. I've written a class with const data members, and I never intended on using assignment on it, but apparently I need assignment to put it in a vector. Is there a way around this that still preserves const-correctness?

    Read the article

  • How can Java assignment be made to point to an object instead of making a copy?

    - by Matthew Piziak
    In a class, I have: private Foo bar; public Constructor(Foo bar) { this.bar = bar; } Instead of creating a copy of bar from the object provided in the parameter, is it possible to include a pointer to bar in the constructor such that changing the original bar changes the field in this object? Another way of putting it: int x = 7; int y = x; x = 9; System.out.print(y); //Prints 7. It is possible to set it up so that printing y prints 9 instead of 7?

    Read the article

  • local variable 'sresult' referenced before assignment

    - by user288558
    I have had multiple problems trying to use PP. I am running python2.6 and pp 1.6.0 rc3. Using the following test code: import pp nodes=('mosura02','mosura03','mosura04','mosura05','mosura06', 'mosura09','mosura10','mosura11','mosura12') def pptester(): js=pp.Server(ppservers=nodes) tmp=[] for i in range(200): tmp.append(js.submit(ppworktest,(),(),('os',))) return tmp def ppworktest(): return os.system("uname -a") gives me the following result: In [10]: Exception in thread run_local: Traceback (most recent call last): File "/usr/lib64/python2.6/threading.py", line 525, in __bootstrap_inner self.run() File "/usr/lib64/python2.6/threading.py", line 477, in run self.__target(*self.__args, **self.__kwargs) File "/home/wkerzend/python_coala/lib/python2.6/site-packages/pp.py", line 751, in _run_local job.finalize(sresult) UnboundLocalError: local variable 'sresult' referenced before assignment Exception in thread run_local: Traceback (most recent call last): File "/usr/lib64/python2.6/threading.py", line 525, in __bootstrap_inner self.run() File "/usr/lib64/python2.6/threading.py", line 477, in run self.__target(*self.__args, **self.__kwargs) File "/home/wkerzend/python_coala/lib/python2.6/site-packages/pp.py", line 751, in _run_local job.finalize(sresult) UnboundLocalError: local variable 'sresult' referenced before assignment Exception in thread run_local: Traceback (most recent call last): File "/usr/lib64/python2.6/threading.py", line 525, in __bootstrap_inner self.run() File "/usr/lib64/python2.6/threading.py", line 477, in run self.__target(*self.__args, **self.__kwargs) File "/home/wkerzend/python_coala/lib/python2.6/site-packages/pp.py", line 751, in _run_local job.finalize(sresult) UnboundLocalError: local variable 'sresult' referenced before assignment Exception in thread run_local: Traceback (most recent call last): File "/usr/lib64/python2.6/threading.py", line 525, in __bootstrap_inner self.run() File "/usr/lib64/python2.6/threading.py", line 477, in run self.__target(*self.__args, **self.__kwargs) File "/home/wkerzend/python_coala/lib/python2.6/site-packages/pp.py", line 751, in _run_local job.finalize(sresult) UnboundLocalError: local variable 'sresult' referenced before assignment any help greatly appreciated

    Read the article

  • Why do not C++11's move constructor/assignment operator act as expected

    - by xmllmx
    #include <iostream> using namespace std; struct A { A() { cout << "A()" << endl; } ~A() { cout << "~A()" << endl; } A(A&&) { cout << "A(A&&)" << endl; } A& operator =(A&&) { cout << "A& operator =(A&&)" << endl; return *this; } }; struct B { // According to the C++11, the move ctor/assignment operator // should be implicitly declared and defined. The move ctor // /assignment operator should implicitly call class A's move // ctor/assignment operator to move member a. A a; }; B f() { B b; // The compiler knows b is a temporary object, so implicitly // defined move ctor/assignment operator of class B should be // called here. Which will cause A's move ctor is called. return b; } int main() { f(); return 0; } My expected output should be: A() A(A&&) ~A() ~A() However, the actual output is: (The C++ compiler is: Visual Studio 2012) A() ~A() ~A() Is this a bug of VC++? or just my misunderstanding?

    Read the article

  • designing classes and objects in .net for a restaurant assignment

    - by Dell Boy
    I have received an assignment at School for creating a Restaurant site. I have to use objects and classes (OOP) for my assignment. I have the foundations of the OOP in .net, but what I don't know is how can I design this assignment to be object-oriented. I don't know how to start it. The requirement is like this: The menu has to be saved in a database and retrieved from it. The menu is devided in appetizers, Salades, Main Meal, Pastas, Wines, Beverages, Extras, Do I create classes like this: Base Class: Menu Derived classes: Appetizers, Salades, Main meal, Pastas, wines, etc. If you have a good example about how to create classes from a Menu that will be great. You don't have to rely on the example I gave above. The menu can be anything. I can deside what the menu will contain. thanks a lot. I am waiting for some help. Please

    Read the article

  • rails delete_all exception

    - by Sergei
    Hello, guys! I have some User model, Role model and Assignment model to manage role-based user system. Just like here . So, here some kind of code, to include roles into users form: <% for role in Role.all %> <%= check_box_tag "user[role_ids][]", role.id, @user.roles.include?(role) %> <%=h role.name %><br /> <% end %> And all's working fine for new records and for editing records. But I just want to make possible to restrict deleting Assigment with id=1, cause this Assignment for default root user from migration, who must be admin anyway. Otherwise, I can lose my last admin. So I've tryed to add before_destroy to Assignment.rb model, but it doesn't work. I've noticed, that when I'm editing user and trying to remove his admin role(assignment), the server makes a delete_all method, not destroy method. So, does anybody know how to catch the deleting of Assignment with id=1 through this kind of code? Thanks in advance!

    Read the article

  • IP assignment in a /28 block

    - by mks
    Need help on setting up firewall router. My config is as below: Public static network ID: x.x.x.48/28 gateway: x.x.x.49 available IP for the hosts: x.x.x.52 to 62 gw_eth0 <-- fw_eth0 - fw_eth1 <-- dmz_switch Four servers are connected on dmz_switch (say s1, s2, s3, s4) all have to use public static IP address from the above block. Any recommendation on IP assignment and route setup? Do I need to subnet the above block further or simply use /32 netmask and point-to-point static routes in the above setup?

    Read the article

  • Personal Virtual Desktop Collection: User Assignment

    - by Fitzroy
    Using Windows Server 2012 Remote Desktop Services, I have a 'Personal Virtual Desktop Collection' with automatic user assignment enabled. According to Microsoft "Personal virtual desktops are permanently assigned to a user account and the user logs on to the same virtual desktop each time." Is there a way either through the Server Manager UI or PowerShell to determine which user has been assigned to which VM? The only way I have found so far is to query the 'Remote Desktop Users' group on each VM in the collection, however that requires each VM to be powered on. There must be a better way.

    Read the article

  • Array Assignment

    - by Mahesh
    Let me explain with an example - #include <iostream> void foo( int a[2], int b[2] ) // I understand that, compiler doesn't bother about the // array index and converts them to int *a, int *b { a = b ; // At this point, how ever assignment operation is valid. } int main() { int a[] = { 1,2 }; int b[] = { 3,4 }; foo( a, b ); a = b; // Why is this invalid here. return 0; } Is it because, array decays to a pointer when passed to a function foo(..), assignment operation is possible. And in main, is it because they are of type int[] which invalidates the assignment operation. Doesn't a,b in both the cases mean the same ? Thanks. Edit 1: When I do it in a function foo, it's assigning the b's starting element location to a. So, thinking in terms of it, what made the language developers not do the same in main(). Want to know the reason.

    Read the article

  • Per client DNS server assignment using Pfsense

    - by Trix
    I have a network where pfsense is the gateway. There are two sets of clients that I want. One where there will be some restrictions to the network (example, IM being blocked) and one network where there are no restrictions. One easy way I thought about doing this was assigning the different domains different DNS servers. One set could use OpenDNS, the other could use Google's Public DNS. The set with OpenDNS would have the filter options on (using OpenDNS' dashboard, I can check block IM .... so I do not manually need to block login.oscar.aol.com, meebo.com, gmail chat ....etc). So the problem is the DHCP server looks like it will only assign a single set of DNS servers to clients. Is there a way to set a per client assignment? Is there a better way to obtain what I want to obtain. This is just a small home network. I do not need anything fancy, but I do need this functionality in one way or another.

    Read the article

  • Mac OS X Client With Static DHCP Assignment Requests Wrong IP via Option 50

    - by Starchy
    I have a number of Mac (and a few Linux) laptops getting DHCP from a Force10 layer 3 switch, the only DHCP server on the subnet. There's a global dynamic pool, and for each full-time employee's laptop I have a single IP static pool set by MAC address. One and only one of the clients, running OS X 10.7.5, consistently fails to get a static assignment. The MAC address in the static pool definition has been carefully re-checked. Running tcpdump on a mirrored port when the laptop connects, I see that it is specifically requesting 10.100.0.252 (a dynamic address): 11:32:10.108280 IP (tos 0x0, ttl 255, id 28293, offset 0, flags [none], proto UDP (17), length 328) 0.0.0.0.bootpc > broadcasthost.bootps: [udp sum ok] BOOTP/DHCP, Request from 3c:07:54:xx:xx:xx (oui Unknown), length 300, xid 0x1399da89, Flags [none] (0x0000) Client-Ethernet-Address 3c:07:54:xx:xx:xx (oui Unknown) Vendor-rfc1048 Extensions Magic Cookie 0x63825363 DHCP-Message Option 53, length 1: Request Parameter-Request Option 55, length 9: Subnet-Mask, Default-Gateway, Domain-Name-Server, Domain-Name Option 119, LDAP, Option 252, Netbios-Name-Server Netbios-Node MSZ Option 57, length 2: 1500 Client-ID Option 61, length 7: ether 3c:07:54:xx:xx:xx Requested-IP Option 50, length 4: 10.100.0.252 Lease-Time Option 51, length 4: 7776000 Hostname Option 12, length 10: "host-name" END Option 255, length 0 PAD Option 0, length 0, occurs 8 I haven't been able to find any extra system prefs or unusual software on the laptop. Disabling the interface and rebooting or temporarily setting the IP manually both fail to make any difference. Any suggestions appreciated.

    Read the article

  • How can I return default at loop end in Scheme?

    - by Kufi Annan
    I'm trying to implement back-tracking search in Scheme. So far, I have the following: (define (backtrack n graph assignment) (cond (assignment-complete n assignment) (assignment) ) (define u (select-u graph assignment)) (define c 1) (define result 0) (let forLoop () (when (valid-choice graph assignment c) (hash-set! assignment u c) (set! result (backtrack n graph assignment)) (cond ((not (eq? result #f)) result)) (hash-remove! assignment u) ) (set! c (+ c 1)) (when (>= n c) (forLoop)) ) #f ) My functions assignment-complete and select-u pass unit tests. The argument assignment is a hash-table make with (make-hash), so it should be fine. I believe the problem I have is related to returning false at the end of the loop, if no recursive returns a non-false value (which should be a valid assignment).

    Read the article

  • Opening Macro definitions: tdfx_span.c: lvalue required as left operand of assignment

    - by anttir
    Hi, I'm trying to compile X11R6-7.0 under Ubuntu maverick and got some weird compilation errors I'm unable to resolve myself. I needed X11R6-7.0 as ati catalyst drivers don't support newer xorg and oss drivers don't support 3d acceleration of my hardware. Anyone know what this error message means? I know some C but I got a bit confused. Does it mean GET_FB_DATA macro returned NULL or some method/property not set? Any further insight how to "debug" preprocessor definitions at this point would be great. I don't think I can print anything useful with #error. The error I get: tdfx_span.c: In function ‘tdfxDDWriteDepthPixels’: tdfx_span.c:976: error: lvalue required as left operand of assignment tdfx_span.c:1008: error: lvalue required as left operand of assignment tdfx_span.c: In function ‘write_stencil_pixels’: tdfx_span.c:1242: error: lvalue required as left operand of assignment the Code: 958- switch (depth_size) { 959- case 16: 960- GetBackBufferInfo(fxMesa, &backBufferInfo); 961- /* 962- * Note that the _LOCK macro adds a curly brace, 963- * and the UNLOCK macro removes it. 964- */ 965- WRITE_FB_SPAN_LOCK(fxMesa, info, 966- GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY); 967- { 968- LFBParameters ReadParams; 969- GetFbParams(fxMesa, &info, &backBufferInfo, 970- &ReadParams, sizeof(GLushort)); 971- for (i = 0; i < n; i++) { 972- if (mask[i] && visible_pixel(fxMesa, x[i], y[i])) { 973- xpos = x[i] + fxMesa->x_offset; 974- ypos = bottom - y[i]; 975- d16 = depth[i]; 976: PUT_FB_DATA(&ReadParams, GLushort, xpos, ypos, d16); 977- } 978- } 979- } 980- WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER); 981- break; 982- case 24: And relative macros: #define GET_FB_DATA(ReadParamsp, type, x, y) \ (((x) < (ReadParamsp)->firstWrappedX) \ ? (((type *)((ReadParamsp)->lfbPtr)) \ [(y) * ((ReadParamsp)->LFBStrideInElts) \ + (x)]) \ : (((type *)((ReadParamsp)->lfbWrapPtr)) \ [((y)) * ((ReadParamsp)->LFBStrideInElts) \ + ((x) - (ReadParamsp)->firstWrappedX)])) #define GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) \ (((type *)((ReadParamsp)->lfbPtr)) \ [(y) * ((ReadParamsp)->LFBStrideInElts) \ + (x)]) #define GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y) \ (((type *)((ReadParamsp)->lfbWrapPtr)) \ [((y)) * ((ReadParamsp)->LFBStrideInElts) \ + ((x) - (ReadParamsp)->firstWrappedX)]) #define PUT_FB_DATA(ReadParamsp, type, x, y, value) \ (GET_FB_DATA(ReadParamsp, type, x, y) = (type)(value)) #define PUT_ORDINARY_FB_DATA(ReadParamsp, type, x, y, value) \ (GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) = (type)(value)) #define PUT_WRAPPED_FB_DATA(ReadParamsp, type, x, y, value) \ (GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y) = (type)(value)) The LFBParameters Struct 483-typedef struct 484-{ 485- void *lfbPtr; 486- void *lfbWrapPtr; 487- FxU32 LFBStrideInElts; 488- GLint firstWrappedX; 489-} 490:LFBParameters; Thanks for looking.

    Read the article

  • I need help on my C++ assignment using MS Visual C++

    - by krayzwytie
    Ok, so I don't want you to do my homework for me, but I'm a little lost with this final assignment and need all the help I can get. Learning about programming is tough enough, but doing it online is next to impossible for me... Now, to get to the program, I am going to paste what I have so far. This includes mostly //comments and what I have written so far. If you can help me figure out where all the errors are and how to complete the assignment, I will really appreciate it. Like I said, I don't want you to do my homework for me (it's my final), but any constructive criticism is welcome. This is my final assignment for this class and it is due tomorrow (Sunday before midnight, Arizona time). This is the assignment: Examine the following situation: o Your company, Datamax, Inc., is in the process of automating its payroll systems. Your manager has asked you to create a program that calculates overtime pay for all employees. Your program must take into account the employee’s salary, total hours worked, and hours worked more than 40 in a week, and then provide an output that is useful and easily understood by company management. • Compile your program utilizing the following background information and the code outline in Appendix D (included in the code section). • Submit your project as an attachment including the code and the output. Company Background: o Three employees: Mark, John, and Mary o The end user needs to be prompted for three specific pieces of input—name, hours worked, and hourly wage. o Calculate overtime if input is greater than 40 hours per week. o Provide six test plans to verify the logic within the program. o Plan 1 must display the proper information for employee #1 with overtime pay. o Plan 2 must display the proper information for employee #1 with no overtime pay. o Plans 3-6 are duplicates of plan 1 and 2 but for the other employees. Program Requirements: o Define a base class to use for the entire program. o The class holds the function calls and the variables related to the overtime pay calculations. o Define one object per employee. Note there will be three employees. o Your program must take the objects created and implement calculations based on total salaries, total hours, and the total number of overtime hours. See the Employee Summary Data section of the sample output. Logic Steps to Complete Your Program: o Define your base class. o Define your objects from your base class. o Prompt for user input, updating your object classes for all three users. o Implement your overtime pay calculations. o Display overtime or regular time pay calculations. See the sample output below. o Implement object calculations by summarizing your employee objects and display the summary information in the example below. And this is the code: // Final_Project.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <string> #include <iomanip> using namespace std; // //CLASS DECLARATION SECTION // class CEmployee { public: void ImplementCalculations(string EmployeeName, double hours, double wage); void DisplayEmployInformation(void); void Addsomethingup (CEmployee, CEmployee, CEmployee); string EmployeeName ; int hours ; int overtime_hours ; int iTotal_hours ; int iTotal_OvertimeHours ; float wage ; float basepay ; float overtime_pay ; float overtime_extra ; float iTotal_salaries ; float iIndividualSalary ; }; int main() { system("cls"); cout << "Welcome to the Employee Pay Center"; /* Use this section to define your objects. You will have one object per employee. You have only three employees. The format is your class name and your object name. */ std::cout << "Please enter Employee's Name: "; std::cin >> EmployeeName; std::cout << "Please enter Total Hours for (EmployeeName): "; std::cin >> hours; std::cout << "Please enter Base Pay for(EmployeeName): "; std::cin >> basepay; /* Here you will prompt for the first employee’s information. Prompt the employee name, hours worked, and the hourly wage. For each piece of information, you will update the appropriate class member defined above. Example of Prompts Enter the employee name = Enter the hours worked = Enter his or her hourly wage = */ /* Here you will prompt for the second employee’s information. Prompt the employee name, hours worked, and the hourly wage. For each piece of information, you will update the appropriate class member defined above. Enter the employee name = Enter the hours worked = Enter his or her hourly wage = */ /* Here you will prompt for the third employee’s information. Prompt the employee name, hours worked, and the hourly wage. For each piece of information, you will update the appropriate class member defined above. Enter the employee name = Enter the hours worked = Enter his or her hourly wage = */ /* Here you will implement a function call to implement the employ calcuations for each object defined above. You will do this for each of the three employees or objects. The format for this step is the following: [(object name.function name(objectname.name, objectname.hours, objectname.wage)] ; */ /* This section you will send all three objects to a function that will add up the the following information: - Total Employee Salaries - Total Employee Hours - Total Overtime Hours The format for this function is the following: - Define a new object. - Implement function call [objectname.functionname(object name 1, object name 2, object name 3)] /* } //End of Main Function void CEmployee::ImplementCalculations (string EmployeeName, double hours, double wage){ //Initialize overtime variables overtime_hours=0; overtime_pay=0; overtime_extra=0; if (hours > 40) { /* This section is for the basic calculations for calculating overtime pay. - base pay = 40 hours times the hourly wage - overtime hours = hours worked – 40 - overtime pay = hourly wage * 1.5 - overtime extra pay over 40 = overtime hours * overtime pay - salary = overtime money over 40 hours + your base pay */ /* Implement function call to output the employee information. Function is defined below. */ } // if (hours > 40) else { /* Here you are going to calculate the hours less than 40 hours. - Your base pay is = your hours worked times your wage - Salary = your base pay */ /* Implement function call to output the employee information. Function is defined below. */ } // End of the else } //End of Primary Function void CEmployee::DisplayEmployInformation(); { // This function displays all the employee output information. /* This is your cout statements to display the employee information: Employee Name ............. = Base Pay .................. = Hours in Overtime ......... = Overtime Pay Amount........ = Total Pay ................. = */ } // END OF Display Employee Information void CEmployee::Addsomethingup (CEmployee Employ1, CEmployee Employ2) { // Adds two objects of class Employee passed as // function arguments and saves them as the calling object's data member values. /* Add the total hours for objects 1, 2, and 3. Add the salaries for each object. Add the total overtime hours. */ /* Then display the information below. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% Total Employee Salaries ..... = 576.43 %%%% Total Employee Hours ........ = 108 %%%% Total Overtime Hours......... = 5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ } // End of function

    Read the article

  • I need help on my C++ assignment using Microsoft Visual C++

    - by krayzwytie
    Ok, so I don't want you to do my homework for me, but I'm a little lost with this final assignment and need all the help I can get. Learning about programming is tough enough, but doing it online is next to impossible for me... Now, to get to the program, I am going to paste what I have so far. This includes mostly //comments and what I have written so far. If you can help me figure out where all the errors are and how to complete the assignment, I will really appreciate it. Like I said, I don't want you to do my homework for me (it's my final), but any constructive criticism is welcome. This is my final assignment for this class and it is due tomorrow (Sunday before midnight, Arizona time). This is the assignment: Examine the following situation: Your company, Datamax, Inc., is in the process of automating its payroll systems. Your manager has asked you to create a program that calculates overtime pay for all employees. Your program must take into account the employee’s salary, total hours worked, and hours worked more than 40 in a week, and then provide an output that is useful and easily understood by company management. Compile your program utilizing the following background information and the code outline in Appendix D (included in the code section). Submit your project as an attachment including the code and the output. Company Background: Three employees: Mark, John, and Mary The end user needs to be prompted for three specific pieces of input—name, hours worked, and hourly wage. Calculate overtime if input is greater than 40 hours per week. Provide six test plans to verify the logic within the program. Plan 1 must display the proper information for employee #1 with overtime pay. Plan 2 must display the proper information for employee #1 with no overtime pay. Plans 3-6 are duplicates of plan 1 and 2 but for the other employees. Program Requirements: Define a base class to use for the entire program. The class holds the function calls and the variables related to the overtime pay calculations. Define one object per employee. Note there will be three employees. Your program must take the objects created and implement calculations based on total salaries, total hours, and the total number of overtime hours. See the Employee Summary Data section of the sample output. Logic Steps to Complete Your Program: Define your base class. Define your objects from your base class. Prompt for user input, updating your object classes for all three users. Implement your overtime pay calculations. Display overtime or regular time pay calculations. See the sample output below. Implement object calculations by summarizing your employee objects and display the summary information in the example below. And this is the code: // Final_Project.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <string> #include <iomanip> using namespace std; // //CLASS DECLARATION SECTION // class CEmployee { public: void ImplementCalculations(string EmployeeName, double hours, double wage); void DisplayEmployInformation(void); void Addsomethingup (CEmployee, CEmployee, CEmployee); string EmployeeName ; int hours ; int overtime_hours ; int iTotal_hours ; int iTotal_OvertimeHours ; float wage ; float basepay ; float overtime_pay ; float overtime_extra ; float iTotal_salaries ; float iIndividualSalary ; }; int main() { system("cls"); cout << "Welcome to the Employee Pay Center"; /* Use this section to define your objects. You will have one object per employee. You have only three employees. The format is your class name and your object name. */ std::cout << "Please enter Employee's Name: "; std::cin >> EmployeeName; std::cout << "Please enter Total Hours for (EmployeeName): "; std::cin >> hours; std::cout << "Please enter Base Pay for(EmployeeName): "; std::cin >> basepay; /* Here you will prompt for the first employee’s information. Prompt the employee name, hours worked, and the hourly wage. For each piece of information, you will update the appropriate class member defined above. Example of Prompts Enter the employee name = Enter the hours worked = Enter his or her hourly wage = */ /* Here you will prompt for the second employee’s information. Prompt the employee name, hours worked, and the hourly wage. For each piece of information, you will update the appropriate class member defined above. Enter the employee name = Enter the hours worked = Enter his or her hourly wage = */ /* Here you will prompt for the third employee’s information. Prompt the employee name, hours worked, and the hourly wage. For each piece of information, you will update the appropriate class member defined above. Enter the employee name = Enter the hours worked = Enter his or her hourly wage = */ /* Here you will implement a function call to implement the employ calcuations for each object defined above. You will do this for each of the three employees or objects. The format for this step is the following: [(object name.function name(objectname.name, objectname.hours, objectname.wage)] ; */ /* This section you will send all three objects to a function that will add up the the following information: - Total Employee Salaries - Total Employee Hours - Total Overtime Hours The format for this function is the following: - Define a new object. - Implement function call [objectname.functionname(object name 1, object name 2, object name 3)] /* } //End of Main Function void CEmployee::ImplementCalculations (string EmployeeName, double hours, double wage){ //Initialize overtime variables overtime_hours=0; overtime_pay=0; overtime_extra=0; if (hours > 40) { /* This section is for the basic calculations for calculating overtime pay. - base pay = 40 hours times the hourly wage - overtime hours = hours worked – 40 - overtime pay = hourly wage * 1.5 - overtime extra pay over 40 = overtime hours * overtime pay - salary = overtime money over 40 hours + your base pay */ /* Implement function call to output the employee information. Function is defined below. */ } // if (hours > 40) else { /* Here you are going to calculate the hours less than 40 hours. - Your base pay is = your hours worked times your wage - Salary = your base pay */ /* Implement function call to output the employee information. Function is defined below. */ } // End of the else } //End of Primary Function void CEmployee::DisplayEmployInformation(); { // This function displays all the employee output information. /* This is your cout statements to display the employee information: Employee Name ............. = Base Pay .................. = Hours in Overtime ......... = Overtime Pay Amount........ = Total Pay ................. = */ } // END OF Display Employee Information void CEmployee::Addsomethingup (CEmployee Employ1, CEmployee Employ2) { // Adds two objects of class Employee passed as // function arguments and saves them as the calling object's data member values. /* Add the total hours for objects 1, 2, and 3. Add the salaries for each object. Add the total overtime hours. */ /* Then display the information below. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% Total Employee Salaries ..... = 576.43 %%%% Total Employee Hours ........ = 108 %%%% Total Overtime Hours......... = 5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ } // End of function

    Read the article

  • LINQ to DataSet Dataclass assignment question

    - by Overhed
    Hi all, I'm working on a Silverlight project trying to access a database using LINQ To DataSet and then sending data over to Silverlight via .ASMX web service. I've defined my DataSet using the Server Explorer tool (dragging and dropping all the different tables that I'm interested in). The DataSet is able to access the server and database with no issues. Below is code from one of my Web Methods: public List<ClassSpecification> getSpecifications() { DataSet2TableAdapters.SpecificationTableAdapter Sta = new DataSet2TableAdapters.SpecificationTableAdapter(); return (from Spec in Sta.GetData().AsEnumerable() select new ClassSpecification() { Specification = Spec.Field<String>("Specification"), SpecificationType = Spec.Field<string>("SpecificationType"), StatusChange = Spec.Field<DateTime>("StatusChange"), Spec = Spec.Field<int>("Spec") }).ToList<ClassSpecification>(); } I created a "ClassSpecification" data class which is going to contain my data and it has all the table fields as properties. My question is, is there a quicker way of doing the assignment than what is shown here? There are actually about 10 more fields, and I would imagine that since my DataSet knows my table definition, that I would have a quicker way of doing the assignment than going field by field. I tried just "select new ClassSpecification()).ToList Any help would be greatly appreciated.

    Read the article

  • FORTRAN: Invalid form for an assignment

    - by Sam Goodness
    I can't get this code to compile uding either the g77 minGW compiler or the g95 compiler. Does anyone know why? I get these errors with the g77: diff5z10.for: In subroutine `diffract': diff5z10.for:579: Tropo100 = 20.34 - .077 * Dist ^ Invalid form for assignment statement at (^) diff5z10.for:581: IF (Freq .GT. 1000) FreqAdj = 24.5 - 7200/(Freq+3000) ^ Invalid form for assignment statement at (^) and i get these errors when compiling with g95: In file diff5z10.for:574 CLUTTER = steep*CLUTTER 1 Error: Unclassifiable statement at (1) In file diff5z10.for:580 FreqAdj = 23.978 - 58026.76 / (Freq + 2320) 1 Error: Unclassifiable statement at (1) here is the code from this section of the program: (starting with line 362) Span = .28 - .144 * (Round - 1.2) Para = C / Span**2 IF (Ratio .GT. .4) Para = 6.25 * (C - 1) CLUTTER = Para * (RATIO - .4)**2 - C IF (CLUTTER .GT. 0.) CLUTTER = 0. CSlope = SQRT(freq)/350 steep = 1 + CSlope * (dist - Horizon) IF (steep .LT. 0) steep = 0 IF (steep .GT. 1) steep = 1 CLUTTER = steep*CLUTTER Tropo100 = 20.34 - .077 * Dist FreqAdj = 23.978 - 58026.76 / (Freq + 2320) IF (Freq .GT. 1000) FreqAdj = 24.5 - 7200/(Freq+3000) TropoFd = Tropo100 - FreqAdj FS_field = 106.9 - 20 * LOG10(Dist) Scatter = TropoFd - FS_field !loss ref to free space DiffL = Scatter - DLOSS Combine = 150/(20 - DiffL) - 5 IF (DiffL .LT. -10) Combine = 0 IF (DiffL .GT. 10) Combine = DiffL DLOSS = DLOSS + Combine RETURN END

    Read the article

  • C: incompatible types in assignment

    - by The.Anti.9
    I'm writing a program to check to see if a port is open in C. One line in particular copies one of the arguments to a char array. However, when I try to compile, it says: error: incompatible types in assignment Heres the code. The error is on the assignment of addr #include <sys/socket.h> #include <sys/time.h> #include <sys/types.h> #include <arpa/inet.h> #include <netinet/in.h> #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <netdb.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(int argc, char **argv) { u_short port; /* user specified port number */ char addr[1023]; /* will be a copy of the address entered by u */ struct sockaddr_in address; /* the libc network address data structure */ short int sock = -1; /* file descriptor for the network socket */ port = atoi(argv[1]); addr = strncpy(addr, argv[2], 1023); bzero((char *)&address, sizeof(address)); /* init addr struct */ address.sin_addr.s_addr = inet_addr(addr); /* assign the address */ address.sin_port = htons(port); /* translate int2port num */ sock = socket(AF_INET, SOCK_STREAM, 0); if (connect(sock,(struct sockaddr *)&address,sizeof(address)) == 0) { printf("%i is open\n", port); } if (errno == 113) { fprintf(stderr, "Port not open!\n"); } close(sock); return 0; } I'm new to C, so I'm not sure why it would do this.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >