Is there a way to translate JAVA to UML Diagrams? Or perhaps software that translate code to UML Diagrams?
Anyone know how to covert .exe, installer back to code and vice versa?
-f Foreground. For the GUI version, Vim will not fork and detach from the shell it was started in.
Ok, I need help with my Java homework. I have to multiply three inputs from users and output the results in a display message. The example shows "10*20*30=6000". I can get it so if the user enters 10, 20 and 30 for the three inputs the display shows 6000. But I can not get it to display the full "10*20*30=6000". Anyone?
Provide more information.Ok, I need help with my Java homework. I have to multiply three inputs from users and output the results in a display message. The example shows "10*20*30=6000". I can get it so if the user enters 10, 20 and 30 for the three inputs the display shows 6000. But I can not get it to display the full "10*20*30=6000". Anyone?
Ok, I need help with my Java homework. I have to multiply three inputs from users and output the results in a display message. The example shows "10*20*30=6000". I can get it so if the user enters 10, 20 and 30 for the three inputs the display shows 6000. But I can not get it to display the full "10*20*30=6000". Anyone?
Have any of you guys taken any digital image processing course in university or know anything about the subject? There is a course I can take next semester (uses this book) and was hoping to get some opinion on the subject.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NullableTypes
{
public struct MyNullable<T> where T : struct
{
public MyNullable(T value)
{
this.hasValue = true;
this.value = value;
}
private bool hasValue;
public bool HasValue
{
get
{
return hasValue;
}
}
private T value;
public T Value
{
get
{
if (!hasValue)
{
throw new InvalidOperationException("no value");
}
return value;
}
}
public static explicit operator T(MyNullable<T> value)
{
return value.Value;
}
public static implicit operator MyNullable<T>(T value)
{
return new MyNullable<T>(value);
}
public override string ToString()
{
if (!HasValue)
return String.Empty;
return this.value.ToString();
}
}
class Program
{
static void Main(string[] args)
{
MyNullable<int> x;
x = 4;
x += 3;
if (x.HasValue)
{
int y = x.Value;
}
}
}
}
Did you read the error? Why didn't you post the error? The text of the error is the single most important thing in fixing the problem. In fact it's often the only thing that matters at all.Does anyone know why the following C# code is giving me an error?
I'm getting an error on the x += 3; line. As far as I can tell this should work.
Operator '+=' cannot be applied to operands of type 'NullableTypes.MyNullable<int>' and 'int'
Did you read the error? Why didn't you post the error? The text of the error is the single most important thing in fixing the problem. In fact it's often the only thing that matters at all.
For the love of god, read and post the error message.
I ran your code for you, and here is the error:
It's not just the += operator, but even the + operator wouldn't work. Your class doesn't overload any of those operators, so you can't simply add an int and a MyNullable<int>.
Here's an msdn page on operator overloading in C# http://msdn.microsoft.com/en-us/library/aa288467(v=vs.71).aspx
You'll find it's more difficult than usual in your case though, since your class is generic. You can't add two arbitrary types T and T, and you can't constrain your types to only things that are addable. You'll probably end up having to implement a bunch of special cases for each type. Here's a stackoverflow question on the topic http://stackoverflow.com/questions/...or-overloading-for-a-generic-class-in-c-sharp
Code:int changeCents = (((cashTendered - totalPrice) - changeLoonies) * 100); printf("Change in cents: %f\n", changeCents); return 0;
Finally found the solution to my problem. I don't even know how I missed something so simple
Yup that's fine.
This is an intro to C programming course, so its being taught like everyone is 100% new to programming in general and not just C. Functions have not been introduced yet. Printf and scanf have as they are the most basic of concepts of programming in C.
To give you an idea of this here is the homepage and where we are at(We have only done up to expressions under week 2 and the computations workshop that I'm doing is suggested at the end of the Expressions section)
I have...it wasn't that exciting of a course, to be honest. A lot of matrix math and Matlab work.
Thanks for the input.
I think I'm just gonna take the computer graphics course instead.
In general, there is significant information lost when you change source code into an executable. Native applications have severe information lost, while some other VM systems like the ones used by Java or C# have less information lost, but it's still significant.Is there a way to convert a desktop application back to source code? I noticed this software was created using Adobe Flash builder, but I do not know how to convert it back to source code (mxml, as, fxg).
Like I said earlier, this solution has a subtle bug in it. You are using binary floating point, which cannot accurately represent all fractional decimal values. For some numbers, the actual value will be slightly more or slightly less than what you want. The C-style implicit float-to-integer cast truncates. Therefore for the values that are slightly less, this approach will generate an answer that is one cent less than the correct value.
Here's an example. Let's say that the closest single-precision binary floating point representation of 3.74 was actually something like 3.73999995 (I'm just making that up as an example, it's not the real value).
If you multiply by 100, you get 373.999995. When you convert to int, it truncates, so you get 373, even the the number you actually wanted was 374.
For home work I have to "write a program that reads a set of integers and then finds and prints the sum of the even and odd integers". My instructor insisted we should use a for/while loop. I know I need to read more on the for/while loops, yet I currently don't recognize how I should structure my code, this is what I have so far.
#include<iostream>
using namespace std;
int main ()
{
int numb1,numb2,numb3;
cout << "Please, enter three integers" << endl;
cin >> numb1 >> numb2 >> numb3;
int sum_even, sum_odd;
for( (numb1 % 2 == 0) )
if num1 % 2 == 0 add it to evenSum
else add it to oddSum
if num2 % 2 == 0 add it to evenSum
else add it to oddSum
...
lol you're in the same school and program as me. Get ready for later classes![]()
Thanks for the tip.
Just for reference, what would be best to use in this situation instead? That fgets() function?
int changeCents = (((cashTendered - totalPrice) - changeLoonies) * 100 + [B]0.5[/B]);
printf("Change in cents: %f\n", changeCents);
return 0;
Are you required to read in an arbitrary amount of integers or do you just need 3? If you need an arbitrary number, you're going to have to use a vector (or something similar) to store the numbers and a loop to read them as well.
You seem to be on the right path with regards to the logic, but if you're only reading in a fixed number of integers, you don't need a loop. You could just say something like
This should already give you an idea of how to loop over the list/vector of integers that you've read.Code:if num1 % 2 == 0 add it to evenSum else add it to oddSum if num2 % 2 == 0 add it to evenSum else add it to oddSum ...
#include<iostream>
using namespace std;
int main ()
{
int numb;
cout << "Please, enter a integer. To calculate the numbers enter 0 " << endl;
cin >> numb;
[I]//Will ask the user for a integer[/I]
int sum_even, sum_odd;
sum_even = 0;
sum_odd = 0;
[I]//variable to determine even/odd[/I]
while( (numb != 0 ) )[I]//keeps the program running until the user decides to press 0 to calculate[/I]
{
if ( (numb % 2) == 0 )[I]//decides if # is even[/I]
{sum_even = sum_even + numb;}[I]//even # will be stored and added[/I]
else if ( (numb % 2) !=0 )[I]//decides if # is odd[/I]
{sum_odd = sum_odd + numb;}[I]//odd # will be stored and added
else [/I]
cout << "You need to enter another input" << endl;
[I] //Will be the recurrent prompt for user until 0 is enter[/I]
cout << "Enter another number ";
cin >> numb;
}
cout << "the sum of all your odd numbers is " << sum_odd << endl;[I]//outputs the sum of odds[/I]
cout << "the sum of all your even numbers is " << sum_even << endl;[I]//outputs the sum of evens
[/I]
system("pause");
}
Are you in CPA by any chance?
Yeah, I'm in CPA but might switch to CPD so I can graduate faster. They're essentially the same thing anyway
Are you doing co-op? Do you know of any of the employers that you can net a job with? That's the only reason why I'm taking CPA over CPD.
Thank you sir! I followed your logic and I have successfully finish the problem
Code:code
From a quick look, this looks good. A few small things:
It doesn't really matter in this case, but don't use system("pause"), just do cin >> numb; at the end. (system("pause") will only work on Windows and it's slow).
You have a lot of good advice, but I kinda laughed a bit when when I got to this.
(It is slow, but given its purpose, that really doesn't matter. Though, you still shouldn't use system("pause") in all but the most hacked-together code.)
Funny you say that my lab instructor was saying I should use return 0;
When you say slow are referring to execution. In comparison how is return 0;
How dooable is the job if you were asked to work on an ongoing JAVA/FLEX project, but there are no technical documents, no technical coworkers, there's one version of the source code ( packaged in a zip file, but not in under version control), and the software is not functional.
The previous programmer left 7 months ago along with most of the work.
Get your debugger ready and start writing tests.How dooable is the job if you were asked to work on an ongoing JAVA/FLEX project, but there are no technical documents, no technical coworkers, there's one version of the source code ( packaged in a zip file, but not in under version control), and the software is not functional.
The previous programmer left 7 months ago along with most of the work.
More common than you'd imagine! Small companies and academia do this annoying thing all the time where they just let stuff languish unfinished, then somebody remembers it and some poor engineer or grad student (depending) finds themselves staring at 40000 lines of wtf.How the fuck did you get stuck with this situation?
public function register_account()
{
/* Create User Account */
$role = 1;
$project_id1 = 1;
$project_id2 = 2;
$email = mysql_real_escape_string($_POST['email']);
$first_name = mysql_real_escape_string($_POST['first_name']);
$last_name = mysql_real_escape_string($_POST['last_name']);
$password = Laravel\Hash::make($_POST['password']);
/* Check if email exists if so change the password on it */
$test_query = "select * from users where email = '$email' and deleted = 0 LIMIT 1";
$test_result = mysql_query($test_query);
if(mysql_num_rows($test_result) >= 1)
{
$query = "
UPDATE `users`
SET
password = '{$password}',
firstname = '{$first_name}',
lastname = '{$last_name}'
WHERE email = '{$email}' AND deleted = 0
LIMIT 1";
return false;
}
else
{
$query = "
INSERT INTO users(
role_id,
email,
password,
firstname,
lastname,
created_at
)VALUES(
'1',
'$email',
'$password',
'$first_name',
'$last_name',
now()
)";
$result = mysql_query($query);
$test_result = mysql_query($test_query);
$row = mysql_fetch_row($test_result);
$query2 = "
INSERT INTO project_users(
user_id,
project_id,
role_id,
created_at,
updated_at
)VALUES(
'$row[0]',
'$project_id1',
'1',
now(),
now()
)";
$result = mysql_query($query2);
$query3 = "
INSERT INTO project_users(
user_id,
project_id,
role_id,
created_at,
updated_at
)VALUES(
'$row[0]',
'$project_id2',
'1',
now(),
now()
)";
$result = mysql_query($query3);
}
return true;
}
d[-_-]b;82951429 said:Little help? Php is a bish... So the first query is called, for inserting into users table but the second two are never called or if they are they throw some sort of error I can't seem to find.
What is the first column of the table `users'? By the way, in code like this, you should never user `*' in a select. First, it's harder to read; Second, what if someone recreate the table and decides, for the kick of it, to change the columns order? Lots of fun.
Also, if you have the errors, that would be great.
"# Create Users Table
CREATE TABLE IF NOT EXISTS `users` (
`id` bigint(20) unsigned NOT NULL auto_increment,
`role_id` bigint(20) unsigned NOT NULL default '1',
`email` varchar(255) default NULL,
`password` varchar(255) default NULL,
`firstname` varchar(255) default NULL,
`lastname` varchar(255) default NULL,
`language` varchar(5) default NULL,
`created_at` datetime default NULL,
`updated_at` datetime default NULL,
`deleted` int(1) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
"# Create Projects Users Table
CREATE TABLE IF NOT EXISTS `projects_users` (
`id` bigint(20) NOT NULL auto_increment,
`user_id` bigint(20) default '0',
`project_id` bigint(20) default '0',
`role_id` bigint(20) default '0',
`created_at` datetime default NULL,
`updated_at` datetime default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
d[-_-]b;82953657 said:As I wish I could figure out how to log errors on php, as a poor developer, thought let me use a free resource aka tinyissue for users to log issues for me to easily track. Bought a vps, worst decision of my life lol, setting up a web server was more work, because apache+php wouldn't let tiny issue work, then someone helped me setup nginx+php to get tinyissue working, originally this all came about from my freehost going down taking my original tinyissue edit with it.
https://github.com/mikelbring/tinyissue/blob/master/install/mysql-structure.php
Long story short... I checked my nginx log folder and don't see any errors logged, also checked php5-fpm log folder and nothing there. Also I made a quick hack to allow users to register as tinyissue doesn't provide a registration page. User registration goes fine but I also need to insert them into the project users table for them to have access to the projects to post issues in.
Just echo data to try to debug? Because my knowledge of php is limited...I really can't see what is wrong from that code. Since it seems to be your code, can you add some error checks on the mysql calls, that could help to pinpoint where it is failing.
d[-_-]b;82971809 said:Just echo data to try to debug? Because my knowledge of php is limited...
$var = mysql_query($query) [B]or trigger_error(...)[/B];
$var = mysql_query($query) or die(mysql_error());
Thanks Hugh, tried switching to using mysql pdo with a prepared statement yeah it didn't give me any errors after I fixed basic syntax errors but still didn't insert into the table, will give what you said a shot when I get home.Sorry for the delay, I had to go to sleep.
http://stackoverflow.com/questions/9619610/how-can-i-debug-why-simplest-mysql-query-returns-false
To get the error from mysql, you'll need to user `mysql_error()' because the calls to mysql_* fail silently.
Calls to mysql_* returns False on failure, so you can do:
Code:$var = mysql_query($query) [B]or trigger_error(...)[/B];
Note that if your page is live, using `trigger_error(...)' could be a security risk as it inserts into the resulting document the location of the script on the file system and the line number where the error occured.
You can also use `die(message)' in place of `trigger_error', which will cause the script to terminate with the message passed as argument.
Code:$var = mysql_query($query) or die(mysql_error());
You get less information but it gives less informations to those who shouldn't see it.
void main()
{
int center = 4;
char board[8][8];
int i, j;
for(i = 0; i < 8; i++)
for(j=0; j < 8; j++)
board[i][j] = "-";
board[center][center] = board[center+1][center+1] = "B";
board[center+1][center] = board[center][center+1] = "W";
}
Have to do a project in C language and I'm having an awful time, can't even get simple statements to make a test from.
For instance say I have this code. (this is just a fragment of the code where I'm getting errors)
Code:void main() { int center = 4; char board[8][8]; int i, j; for(i = 0; i < 8; i++) for(j=0; j < 8; j++) board[i][j] = "-"; board[center][center] = board[center+1][center+1] = "B"; board[center+1][center] = board[center][center+1] = "W"; }
Every time I try to assign a value such as "-", "B", or "W" I get an error stating:
"assignment makes integer from pointer without a cast [enabled by default]"
Can someone help me work this out?
chars are assigned with ' ', not " ".
You might want to use some braces and depending on the environment int main() instead of void main().
int k;
for(k = 1; k <= 8; k++){
printf(k);
}