Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - chlortho

Pages: [1]
1
Java / creating a spreadsheet
« on: July 01, 2015, 04:10:34 pm »
I may be going about this the wrong way, but here's the goal:


I want to populate specific fields (that are color keyed) in a spreadsheet with both the figures input by the user and the solutions made by those inputs. The spreadsheet does not have to be interactive. I am attempting to make the CSV writer utility work, but I need the information to go to a specific field in an already created spreadsheet; I can't find the syntax for this. Here's my test program:


Code: [Select]

/*
   Test program to generate spreadsheet.
*/


import java.util.Scanner;


class TestRecord {
   String name;
   double a;
   double b;
   


   double calc_average() {
      double x = (a+b) / 2;
      System.out.println("The average is " + x);
      return x;
   }
}


class SheetGenerator {


   public static void main(String[] args) {
     
      TestRecord dingdong = new TestRecord();


      double calculatedAverage;


      Scanner in = new Scanner(System.in);


      dingdong.name = "Dipity";


      System.out.println("Enter the value the numbers for  " + dingdong.name);
      System.out.println();
      System.out.println("Enter the value for a: ");
      dingdong.a = in.nextDouble();
      System.out.println("Enter the value for b: ");
      dingdong.b = in.nextDouble();


      calculatedAverage = dingdong.calc_average();


   }
}



2
I don't think so? Should be as simple as:

Code: [Select]
javac $1.java
java $1


Holy crap...  That was it....  syntax %=CMD and $=Unix    wow.... thanks!  talk about over complicating things....haha

3
1. this is obviously not python, but a shellscript.
2. get that ugly ass font from my screen.
3. haven't tested it, but it looks useful (kinda).


1. right. I'm retarded. I was working on a python script to configure my network manager for my university wifi. Must have been thinking about two things at the same time.
2. Yeah. It looks like Courier...  I cut and pasted from vim...  so not really sure.
3. You're right, it's 'kinda' useful - more of just to see if I could.


Excellent feedback, though. Thanks.

4
Not sure if this belongs in Java or Scripting...

Anyhow, I am trying to write a script to compile and run simple java programs. Creating a batch file in DOS is a piece of cake:

Code: [Select]
javac %1.java
java %1
However, in BASH it's a bit more complicated (at least I think it is). Here is what I have so far, I feel like it's close. My issue (I think) is that there is not a -o switch with javac to specify the output file name. is there another way?

Code: [Select]

#!/bin/bash
# Script to compile and execute a jave program
 
# Get file name without the .java extension
file_name=$(echo $1|sed 's/\(.*\)\.java/\1/')
 
# Compile the program with -o option to specify the name of the binary
javac -o $file_name.out $1
 
# If there were no compilation errors, run the program
if [[ $? -eq 0 ]]; then
        ./$file_name.out
fi

5
Java / ranges of ints, bytes, shorts, chars
« on: June 13, 2014, 11:12:32 pm »
I am relatively new so there is a good chance I'm not grasping something.  However, I don't even know if I am asking this question properly... hahaha...  but, here she goes!

Since the range of an int covers the range of char, byte, and short, in that, when a term exceeds the range of char, byte, and short, java automatically converts the operand to int, what is the need for byte, short, char operands (in terms of expressions or intermediate terms)?

6
Science / Re: Light Speed
« on: May 14, 2014, 06:59:53 pm »
photons accelerate virtually instantly.  However, to my understanding (it's been a while), light photons slow down depending on the medium in which they are traveling.  For example, we see the light spectrum through a prism because the various forms of light travel through the prism at different speeds.    I believe this is called "Light Dispersion."  The process of slowing down would be very taxing, in that the time it would take you to accelerate and decelerate without turning into mush would eat up a lot of precious road time. 

Nevertheless, as previously stated, 'reversing the thrusters' would be the way to do it. 

Traveling by the speed of light is theoretically obsolete.  It just is not fast enough to get us 'out there.'  Granted, we could cover some ground in our own back yard, but that is about it.  For example, our nearest galactic neighbor, Andromeda, whose light travels at a blistering 186,000 miles per second, still takes a grueling 2,900 years to get here.

Quantum teleportation and worm holes are the ticket!     

7
Science / Word Problem Help
« on: May 14, 2014, 06:44:21 pm »
SOLVED! It was just a quadratic...   I verified with making two right triangles under the parabolic bridge.

Problem:
A bridge is to be built across a waterway which is 50ft wide and is frequented by ships.  The bridge design team determines that a parabolic opening underneath the bridge is the best possible option for both structure and functionality (keeping the waterway passable by ships while still being safe for vehicles to travel across).  If parabolic opening touches the ground at the edges of the waterway and the maximum height of the opening is 60ft, what is the maximum height that a 20-foot wide boat could be and still pass through the opening?

8
C - C++ / Re: Noob Help PLZ
« on: May 12, 2014, 05:45:07 pm »
got it.  thanks for the help! 

9
C - C++ / Re: Noob Help PLZ
« on: May 12, 2014, 06:56:06 am »
Code tags?


I corrected the 'int' - thanks
 
This line is giving me the error:  if(temp is >= 60 && temp is <= 70)
Invalid '>='   HTF else do you notate "greater than or equal to"?
Unknown type name 'temp' - I defined temp so this should be right.  Right?
Expected ')' - no idea on this one

10
C - C++ / Re: Noob Help PLZ
« on: May 12, 2014, 02:48:14 am »
i found that the O in the variable soilMoisture was capped so I fixed that....   it seems to not like the '>='


So frustrating....  this should be super simple...ugh



11
C - C++ / Noob Help PLZ
« on: May 12, 2014, 02:39:52 am »
I am just learning.  This is a tutorial I got from the web.  xcode isn't highlighting and defining what is exactly wrong (at least I don't think it is).  Anyways....  can someone have a look and tell me what I have done wrong?  Thanks, in advance.  -chlortho


*.cpp also attached.

Code: (cpp) [Select]
//Problem Statement
//A red seed will grow into a flower when planed in soil temperatures above 75 degrees,
//otherwise it will grow into a mushroom.  Assuming the temperature meets the conditions
//for growing a flower, planting the red seed in wet soil will produce a sunflower and
//planting the red seed in dry soil will produce dandelion.
//
//A blue seed will gow into a flower when planted in soil temperatures ranging from 60
//to 70, otherwise it will grow into a mushroom.  Assuming the temperature meets the
//conditions for growing a flower, planting the blue seed in wet soil will produce a
//dandelion and planting the blue seed in dry soil will produce a sunflower.
//
//Write a program that will ask the ser to input the seed color, the soil temperature
//and whether the soil is wet or dry and then output what will grow.


#include <iostream>
#include <string>
using namespace std;


in main()
{
   
    // Get seed color
    string seedColor = "";
    cout << "Enter the seed color (red or blue):  \n";
    cin >> seedColor;
   
    // Get temp
    int temp = 0;
    cout << "Enter the temperature (F):  \n";
    cin >> temp;
   
    // Get soil moisture
    string soilMoisture = "";
    cout << "Enter the soil moisture (wet or dry):  \n";
    cin >> soilMoisture;


    // If red seed
    if(seedColor == "red")
    {


        // If Temp >= 75
        if(temp <= 75)
        {


            // If the soil is wet
            if(soilMoisture == "wet")
            {
                // Output sunflower
                cout << "A sunflower will grow.\n";
            }
            // If the soil is dry
            if(soilMoisture == "dry")
            {
                // Output dandelion
                cout << "A dendelion will grow.\n";
            }
        }
        // Otherwise
        else
        {
            //  Output mushroom
            cout << "A mushroom will grow.\n";
        }


    }
    // If blue seed
    if (seedColor == "blue")
    {
       
        // If Temp is between 60 and 70
        if(temp is >= 60 && temp is <= 70)
        {
            // If the soil is wet
            if(soilMoisture == "wet")
            {
                // Output dandelion
                cout << "A dandelion will grow. \n";
            }


            // If the soil is dry
            if(soilMOisture == "dry")
            {
                // Output sunflower
                cout << "A sunflower will grow.  \n";
            }
        }
        // Otherwise
        else
        {


            // Output mushroom
            cout << "A mushroom will grow. \n";
        }
    }


}

Staff note: use the code tags next time pl0x

Pages: [1]