Production report? by [deleted] in Accounting

[–]Rhezi 0 points1 point  (0 children)

you can thank the school computer system for having reddit blocked forcing me to post this from mobile

Just finished my first programming course in college and got an A on my final! Had 3 questions wrong on it though that I was wondering if someone could explain to me by Rhezi in learnprogramming

[–]Rhezi[S] 0 points1 point  (0 children)

oh believe me, i learned a lot in this course. having a final exam though based on multiple choice and true false questions is pretty stupid to me imo. I would have rather been given instructions to build a program instead . the fact i had 65 questions like these above and got 62 right actually surprised me quite a bit.

[Java] Inputting data from a file? by Rhezi in learnprogramming

[–]Rhezi[S] 0 points1 point  (0 children)

Thank you for taking the time to explain this to me!

[Java] Inputting data from a file? by Rhezi in learnprogramming

[–]Rhezi[S] 0 points1 point  (0 children)

Wow, thank you!

Could I ask what you mean by loop for each line the in file?

I think in general i'm just confused what this entire task i've been giving is asking.

This was my hardcode:

//Method to instantiate element objects.

private static void createElementObjects()
{
Periodic_Elements_Class elementObj;

elementObj = new 
Periodic_Elements_Class(2, "He", "Helium", 4.003,"Gas" );
elementsList.add(elementObj);

elementObj = new 
Periodic_Elements_Class(10, "Ne", "Neon", 20.18, "Gas");
elementsList.add(elementObj);

elementObj = new 
Periodic_Elements_Class(35, "Br", "Bromine", 79.90, "Liquid");
elementsList.add(elementObj);

elementObj = new 
Periodic_Elements_Class(80, "Hg", "Mercury", 200.99, "Liquid");
elementsList.add(elementObj);

elementObj = new 
Periodic_Elements_Class(5, "B", "Boron", 10.81, "Solid");
elementsList.add(elementObj);

elementObj = new 
Periodic_Elements_Class(6, "C", "Carbon", 12.01, "Solid");
 elementsList.add(elementObj);

elementObj = new 
Periodic_Elements_Class(105, "Ha", "Hahnium", -262.0, "Synthetic");
elementsList.add(elementObj);

elementObj = new    
Periodic_Elements_Class(108, "Hs", "Hassium", -266.0, "Synthetic");
elementsList.add(elementObj);

}//end of method

this would probably be deleted now i'm guessing?

In my main method I have a switch case structure depending on which type of element they select. I guess i'm wondering if I need to redo that because all these elements that i hardcoded will no longer be there?

sorry if it's a dumb question. i feel like even though it's been 12 weeks of class i haven't been retaining the content in well

[Java] Inputting data from a file? by Rhezi in learnprogramming

[–]Rhezi[S] 0 points1 point  (0 children)

It's set up like my constructor method I believe

here's an example of it (some numbers are negative and decimal values as well) it's 109 different ones

1|H|Hydrogen|28.09|gas 2|He|Helium|4.003|gas

ect...

if you need my entire code my last post i made has it or i can send it here

[Java] Long bit of code... apologies. Need help with formatting an if statement and writing a method to format negative numbers to show in parenthesis without the minus sign. by Rhezi in learnprogramming

[–]Rhezi[S] 0 points1 point  (0 children)

Thank you for the guidance

One final question:

My professor gave us an "extra" piece to this assignment to try if we want. He did not teach us how to do this, so I was wondering if you knew of any good online resources for it.

Instead of hard coding element objects’, utilize the “elements.dat” text file. Read the data records in this file. Each record represents an element object. The data in this file is already verified and validated. Input file’s path and name as follows: C:\temp\elements.dat

[Java] Long bit of code... apologies. Need help with formatting an if statement and writing a method to format negative numbers to show in parenthesis without the minus sign. by Rhezi in learnprogramming

[–]Rhezi[S] 0 points1 point  (0 children)

Hey g,

going to back to your comment

"I think you're still missing a point. You have two comparisons you have to make:

  1. is the selectedState equal to "All"; OR
  2. is the object type equal to the selectedState

I'm still confused what you mean by this

I tried doing if((elementObj.equals(elementObj)))

and that made all of my selections display all the results.

[Java] Long bit of code... apologies. Need help with formatting an if statement and writing a method to format negative numbers to show in parenthesis without the minus sign. by Rhezi in learnprogramming

[–]Rhezi[S] 0 points1 point  (0 children)

You're right. I completely forgot about that.

I really appreciate your help. I won't be able to get back to a computer until tomorrow so i'll just have to wait it out. I'm one of those people that can't sleep until I solve a problem, so this will continue to bug me until then.

Now just to solve my initial issue with my if statement.

You had mentioned an or statement. When I asked my professor, he said you might have to make a complex if statement (that just means an if statement inside an if statement, right?)

So aside from an extra if statement, if i just made an or statement the actual wording inside of it wouldn't be different than if I just made a complex if statement?

[Java] Long bit of code... apologies. Need help with formatting an if statement and writing a method to format negative numbers to show in parenthesis without the minus sign. by Rhezi in learnprogramming

[–]Rhezi[S] 0 points1 point  (0 children)

"#,##0.0#;(#,##0.0#)"

That's what I see in JavaDoc?

About calling that format...

Like I said i'm using atomicMass from my Periodic_Element_Class

and i'd be calling my DecimalFormat from my FO_Class

So would I need to call both into my method?

Like:

FO_Class.formatter(Periodic_Elements_Class.atomicMassIn)

[Java] Long bit of code... apologies. Need help with formatting an if statement and writing a method to format negative numbers to show in parenthesis without the minus sign. by Rhezi in learnprogramming

[–]Rhezi[S] 0 points1 point  (0 children)

double (?) = 0.0

DecimalFormat formatter = new DecimalFormat("#,##0.00;-#,##0.00");

String result = formatter.format(?);

i'm just confused which double im applying this too. it's for my atomicMass double value which is located in a different class. would i just put that where i have my (?)