NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
G.Mark Stewart Posted via mailing list.
|
Posted: Thu Sep 10, 2009 5:58 pm Post subject: Folks - a Newbie ??? |
|
|
The program compiles, runs up to the first prompt, outputs the prompt,
and then
ignores any response keystrokes. What gives? Any ideas?
Thanks!
package cis261_lab1;
import java.util.Scanner; // program uses class Scanner
/**
*
* @author gmark
*/
public class Calculate {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// create a Scaner to obtain input from the command window
Scanner input = new Scanner( System.in );
int first; // first number to process
int second; // second number to process
int sum; // sum
int product; // product
int difference; // difference
int quotient; // quotient
System.out.print( "Enter first integer: " );
first = input.nextInt(); // read first integer from user
System.out.print( "Enter second integer: " );
second = input.nextInt(); // read second integer from user
sum = first + second; // add numbers, then store value in sum
product = first * second; // multiply numbers, then store
value in product
difference = first - second; // subtract numbers, then store
value in difference
quotient = first / second; // divide numbers, then store value
in quotient
sum = first + second; // add
numbers, then store value in sum
System.out.println( "Sum is " + sum );
System.out.println( "Product is " + product );
System.out.println( "Difference is " + difference );
System.out.println( "Quotient is " + quotient );
} // end method main
} // end class Calculate |
|
| Back to top |
|
 |
Melongo Annabel Posted via mailing list.
|
Posted: Fri Sep 11, 2009 12:59 am Post subject: Folks - a Newbie ??? |
|
|
To better assist, it would be nice to provide the log errors as well. Thanks.
From: G.Mark Stewart <address-removed>
To: address-removed
Cc: G.Mark Stewart <address-removed>
Sent: Thursday, September 10, 2009 9:21:30 AM
Subject: [nbusers] Folks - a Newbie ???
The program compiles, runs up to the first prompt, outputs the prompt, and then
ignores any response keystrokes. What gives? Any ideas?
Thanks!
package cis261_lab1;
import java.util.Scanner; // program uses class Scanner
/**
*
* @author gmark
*/
public class Calculate {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// create a Scaner to obtain input from the command window
Scanner input = new Scanner( System.in );
int first; // first number to process
int second; // second number to process
int sum; // sum
int product; // product
int difference; // difference
int quotient; // quotient
System.out.print( "Enter first integer: " );
first = input.nextInt(); // read first integer from user
System.out.print( "Enter second integer: " );
second = input.nextInt(); // read second integer from user
sum = first + second; // add numbers, then store value in sum
product = first * second; // multiply numbers, then store value in product
difference = first - second; // subtract numbers, then store value in difference
quotient = first / second; // divide numbers, then store value in quotient
sum = first + second; // add numbers, then store value in sum
System.out.println( "Sum is " + sum );
System.out.println( "Product is " + product );
System.out.println( "Difference is " + difference );
System.out.println( "Quotient is " + quotient );
} // end method main
} // end class Calculate |
|
| Back to top |
|
 |
G.Mark Stewart Posted via mailing list.
|
Posted: Fri Sep 11, 2009 7:19 am Post subject: Folks - a Newbie ??? |
|
|
Well, there were no errors -- the program just stopped as though I hadn't typed anything. ButI just ran it again today and it worked. No idea why.
I do have a problem with the C++ program, however. It doesn't recognize "cout", and I'm told
I have to in that the build not recognizing <iostream>. I've been told to add
the collection of cygwin tools to Netbeans 6.0 by going to the Tools -> Options
menu item.
Problem is that the top window menu bar on my machine does not have an "options" selection under
"tools". I'm going to try to reinstall the Netbeans IDE, just in case it's not a "version" problem,
but just a bad install of Netbeans.
Perhaps there's a work-around? Some other way of accessing this or putting a more complete path
into the #include statement? The basic issue is simply that the build blows up on the use of
"cout". For that matter, I don't mind using a command-line compiler method, if this is just
some limitation of Netbeans.
I've attached the output log and source below in case that above is not sufficiently explanatory.
Thanks!
Mark
On Sep 10, 2009, at 7:59 PM, Melongo Annabel wrote:
| Quote: | To better assist, it would be nice to provide the log errors as well. Thanks.
From: G.Mark Stewart <address-removed ([email]address-removed[/email])>
To: address-removed ([email]address-removed[/email])
Cc: G.Mark Stewart <address-removed ([email]address-removed[/email])>
Sent: Thursday, September 10, 2009 9:21:30 AM
Subject: [nbusers] Folks - a Newbie ???
The program compiles, runs up to the first prompt, outputs the prompt, and then
ignores any response keystrokes. What gives? Any ideas?
Thanks!
|
Running "/usr/bin/make -f Makefile CONF=Debug" in /Users/gmark/NetBeansProjects/CIS246-Lab1
/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
mkdir -p build/Debug/GNU-MacOSX
gcc -c -g -o build/Debug/GNU-MacOSX/main.o main.c
main.c:13:22: error: iostream.h: No such file or directory
main.c:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std'
main.c:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std'
main.c:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'isCorrect'
main.c: In function 'sumprodiq':
main.c:39: error: 'cout' undeclared (first use in this function)
main.c:39: error: (Each undeclared identifier is reported only once
main.c:39: error: for each function it appears in.)
main.c:39: error: 'endl' undeclared (first use in this function)
main.c:40: error: 'cin' undeclared (first use in this function)
main.c:50: error: expected ';' before string constant
main.c:50:74: warning: missing terminating " character
main.c:50: error: missing terminating " character
main.c:51:16: warning: missing terminating " character
main.c:51: error: missing terminating " character
make[1]: *** [build/Debug/GNU-MacOSX/main.o] Error 1
make: *** [.build-impl] Error 2
Build failed. Exit value 2.
/*
* File: main.c
* Author: gmark
*
* Created on September 9, 2009, 6:43 PM
*/
// Exercise 1 Solution
// Calculate and print the sum, product, difference, and quotient (division)
// of two entered numbers.
#include <stdlib.h>
#include <iostream.h>
using std::cin;
using std::cout;
void sumprodiq(); // function prototype
bool isCorrect( int, int ); // function prototype
int main()
{
sumprodiq();
return 0; // indicate successful termination
} // end main
void sumprodiq()
{
int first; // requested first number
int second; // requested second number
int sum; // Sum
int prod; // Product
int diff; // Difference
int quot; // Quotient
// prompt for first number
cout << "Please type your first number." << endl << "? ";
cin >> first;
// prompt for second number
cout << "Please type your second number." << endl << "? ";
cin >> second;;
sum = first + second;
prod = first * second;
diff = first - second;
quot = first / second;
cout << "Sum is ", sum ", product is ", prod ", difference is ", diff ",
quotient is " quot;
} // end function sumprodiq |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|