CurtisBridges 6 Light Poster

/*Please help. I'm trying to throw an IllegalArgumentException.
*If any test score in the array is negative or greater than 100
*using a try block, but am having little if any progress after 9 hours of work.
* I am still getting an error mesage saying illegal start of expression and ) expected on line 48.
*The program will compute the average and display an Error invalid Score!message for average over 100
* but only calculates the - average without the Error invalid Score! message.
*Please help to make this work.
*
*
*Instructions:
Write a class named TestScores.
The class constructor should accept an array of test scores as its argument.
The class should have a method that returns the average of the test scores.
If any test score in the array is negative or greater than 100, the class should throw an IllegalArgumentException.
Demonstrate the class in a program.

*/

import java.io.*; // For File class and FileNotFoundException
import java.util.Scanner;// For Keyboard input

public class TestScores {



    public static void main(String[] args){
     
        //Variable Declarations
        Scanner keyboard = new Scanner(System.in);
        int TestScore =0;
        int testScore1=0;
        int testScore2=0;
        int testScore3=0;
        int averageScore;
        int userInput; 
        
        
        
            //User Prompts
            System.out.print("Please enter your 1st test score: ");
            testScore1 = keyboard.nextInt();
            System.out.print("Please enter your 2nd test score: ");
            testScore2 = keyboard.nextInt();
            System.out.print("Please enter your 3rd test score: ");
            testScore3 = keyboard.nextInt();
    
            
  
            //Array to hold user input
            int [0,1,2]TestScores = …
CurtisBridges 6 Light Poster

Thank you very much,Ezzara. l will leave a message for the smart one iamthwee maybe you should look for a different line of work. That is what I'm doing.I am 51 years old equipment operator that suffered a brain anuerisym and stroke, leaving me with partial use of my left hand and confined to a wheelchair(you know paralized)i I try not to share my condition with everyone, but people like you just bring out the best in me. By the way I'm ttrying to learn this online as a new way to support my family. Have a nice day you smart-ass!

jwenting commented: not smart -2
CurtisBridges 6 Light Poster

I seem to really be lost. I have included the instructions for this problem, for you clarity only. I'm not asking you to do the work.I really want to learn java. I have read this complete chapter Three times now and seem to not be getting through my thick skull what I should add to this code from the second file (shown below).If you could show me the syntax for calling the setter/getters and how to implement the first if statement. I think i could finish the project.


A software company sells a package that retails for $99. Quantity discounts are given according to the following table:
Quantity Discount
10–19 20% 20–49 30% 50–99 40% 100 or more 50%
Design a class that stores the number of units sold and has a method that returns the total cost of the purchase.

import java.util.Scanner;

class SoftwareSales {
    
    public static void main(String[] args) {
   
    // Data Members
   String software, discount, or, more;
   double sales, product, units, number;
    
   
    Scanner keyboard = new Scanner(System.in);{
    
    
        System.out.print("Please enter the number of units sold.");
          keyboard.nextDouble();


import java.util.Scanner;

class SoftwareSales {
    
    public static void main(String[] args) {
   
    // Data Members
   String software, discount, or, more;
   double sales, product, units, number;
    sales = 99;
   
    Scanner keyboard = new Scanner(System.in);{
    
    
       System.out.print("Please enter the number of units sold.");
    keyboard.nextDouble();
    
    if (units < 10)
    (units * sales);
  else if (units > 9 && < 20)
(99 - (99 * 0.2));
  else if (units > 19 …
CurtisBridges 6 Light Poster

I have written a program that work as supposed to, except the output needs to be in 2 cols. instead of 1 col. in console. Could someone help me to format this?

Below is the program and the output I need to change. 14.14.cpp : Defines the entry point for the console application.

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <fstream>
using std::cout;
using std::endl;
using std::cerr;
using std::setw;
using std::ofstream;
using std::ifstream;
 
int main()
{
 
ofstream outFile("datasize.dat");
 
cout << "Data type" << setw(16) << "Size\nchar"
<< setw(21) << sizeof(char)
<< "\nunsigned char" << setw( 12 ) << sizeof(unsigned char)
<< "\nshort int" << setw( 16 ) << sizeof(short int)
<< "\nunsigned short int" << setw( 7 ) << sizeof(unsigned short)
<< "\nint" << setw( 22 ) << sizeof(int) << '\n';
 
cout << "unsigned int" << setw( 13 ) << sizeof(unsigned)
<< "\nlong int" << setw( 17 ) << sizeof( long )
<< "\nunsigned long int" << setw( 8 ) << sizeof(unsigned long int)
<< "\ndouble" << setw ( 20 ) << sizeof (double)
<< "\ndouble" << setw ( 19 ) << sizeof (double)
<< "\nlong double" << setw (14) << sizeof (long double)<< endl;
 
return 0;
}

Data type Size
char 1
unsignedchar 1
shortint 2
unsignedshortint 2
//need to split col. here.:cheesy: :cheesy: :cheesy: :cheesy:
int 4
unsignedint 4
longint 4
unsignedlongint 4
double 8
double 8
longdouble 8
Press any key to …

CurtisBridges 6 Light Poster

Exceptions

--------------------------------------------------------------------------------
I am working on a class project as layed out by the instructor. This is in conjunction with Chapter 13 (Exceptions) from the book How To Program in C++ by Deitle 4/e. I am at a total loss on this subject. I thought that catching problems was up to the compiler. I have included Figure 13.1 for an example as per instructions and some code I have been working on. Could someone please look this over and help me get my brain around exceptions or at least this project?


// Fig. 13.1: fig13_01.cpp
// A simple exception-handling example that checks for
// divide-by-zero exceptions.

#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <exception>
using std::exception;
// DivideByZeroException objects should be thrown by functions
// upon detecting division-by-zero exceptions
class DivideByZeroException : public exception {
public:
// constructor specifies default error message
DivideByZeroException::DivideByZeroException()
: exception( "attempted to divide by zero" ) {}
}; // end class DivideByZeroException
// perform division and throw DivideByZeroException object if 
// divide-by-zero exception occurs
double quotient( int numerator, int denominator )
{
// throw DivideByZeroException if trying to divide by zero
if ( denominator == 0 )
throw DivideByZeroException(); // terminate function
// return division result
return static_cast< double >( numerator ) / denominator;
} // end function quotient
int main()
{
int number1; // user-specified numerator
int number2; // user-specified denominator
double result; // result of division
cout << "Enter two integers (end-of-file to …
CurtisBridges 6 Light Poster

Exceptions
I am working on a class project as layed out by the instructor. This is in conjunction with Chapter 13 (Exceptions) from the book How To Program in C++ by Deitle 4/e. I am at a total loss on this subject. I thought that catching problems was up to the compiler. I have included Figure 13.1 for an example as per instructions and some code I have been working on. Could someone please look this over and help me get my brain around exceptions or at least this project?

// Fig. 13.1: fig13_01.cpp
// A simple exception-handling example that checks for
// divide-by-zero exceptions.
Code: 
#include <iostream>using std::cout;using std::cin;using std::endl;#include <exception>using std::exception;// DivideByZeroException objects should be thrown by functions// upon detecting division-by-zero exceptionsclass DivideByZeroException : public exception {public:   // constructor specifies default error message   DivideByZeroException::DivideByZeroException()      : exception( "attempted to divide by zero" ) {}};  // end class DivideByZeroException// perform division and throw DivideByZeroException object if // divide-by-zero exception occursdouble quotient( int numerator, int denominator ){   // throw DivideByZeroException if trying to divide by zero   if ( denominator == 0 )      throw DivideByZeroException(); // terminate function   // return division result   return static_cast< double >( numerator ) / denominator;}  // end function quotientint main(){   int number1;    // user-specified numerator   int number2;    // user-specified denominator   double result;  // result of division   cout << "Enter two integers (end-of-file to end): ";   // enable user to enter two integers to divide   while ( cin >> number1 >> number2 ) {         // try …
iamthwee commented: use code tags -2
CurtisBridges 6 Light Poster

You can drop the inheritance and put in the Circle class a private data member center of type point. This way you would be able to use all the methods of the Point class on the center of the circle while keeping the design of Circle class intact.

class Circle:public Point3d
{
    // all the members
} ;
 
// with composition
class Circle
{
    Point3d* pt ;   // or Point3d pt, your call
 
   // other circle members 
} ;

Also read this and this.

Thanks for the help and he links thatwas good info. Merry Christmas

~s.o.s~ commented: Merry Christmas, I like your manners - ~s.o.s~ +9
CurtisBridges 6 Light Poster

Sorry, about that. I posted incorrect file. Hope this makes more sense.

#ifndef CIRCLE4_H
#define CIRCLE4_H
#include "point3.h" // Point3 class definition
class Circle4 : public Point3 {
public:
// default constructor
Circle4( int = 0, int = 0, double = 0.0 ); 
void setRadius( double ); // set radius
double getRadius() const; // return radius
double getDiameter() const; // return diameter
double getCircumference() const; // return circumference
double getArea() const; // return area
void print() const; // output Circle4 object
private: 
double radius; // Circle4's radius
}; // end class Circle4
#endif
CurtisBridges 6 Light Poster

I recommend you read the Wikipedia article and see if that clears things up. ;)

Thanks, Been there, Done that. Just more confused.

CurtisBridges 6 Light Poster

//I need to change this program from using inheritance to using composition.
//Could someone please show me how? I have two other programs that I can surely do myself.
//I'm really in search of a sample.

// Fig. 9.17: point3.h
// Point3 class definition represents an x-y coordinate pair.

#ifndef POINT3_H
#define POINT3_H
class Point3 {
public:
Point3( int = 0, int = 0 ); // default constructor
void setX( int ); // set x in coordinate pair
int getX() const; // return x from coordinate pair
 
void setY( int ); // set y in coordinate pair
int getY() const; // return y from coordinate pair
 
void print() const; // output Point3 object
private: 
int x; // x part of coordinate pair
int y; // y part of coordinate pair
}; // end class Point3
#endif
CurtisBridges 6 Light Poster

We got it Thanks for the tips Walt.

CurtisBridges 6 Light Poster

At row 378 I have started search function, but I'm not sure where to go with it from here as far as setting up the recursive alg. part of the code I don't need my exact program written, a genral snippet showing the code for showing this particular step is all I'm asking for. The directions were posted just so the existing code would be more easily understood as requested.

CurtisBridges 6 Light Poster

... does that really mean
I don't see a question in your post.

No! That's not what I'm after. I'm just looking for some help on the rec. binary search and sort. Thank You.

CurtisBridges 6 Light Poster

Here's a better explantion. Thanks!
This part"A" is already finished:
A). Create a menu with the following options, (1) Add, (2) Update, (3) Delete, (4) Sort, (5) Print, and (6) Quit.
Create an array of 10 strings up to 25 characters long and initialize each one to "none". Each item will represent a first name.
Create an array of function pointers to each of the above menu options. When the user selects an option call the appropriate function using this array.
Pass the string array to each of the functions as a parameter.
Use a bubble sort to sort the items.
Display the array when the user selects a menu item (except Sort, Print, and Quit) and then prompt the user for the nmnber (use the array subscript) of the item they want to operate on.
When deleting a name set it back to "none".
When deleting a name first confirm that the user wants to continue with the delete.
This is part"B" which has been added:
B). //I need to modify this code by changing the(existing) sort function to make it recursive
//and add a recursive binary search that prompts the user to enter a search item.
//I have added some code for the search, which I will mark with
// :?: commented out on previous line. Please help finsh with recursion. I'm lost.
//:mrgreen: denotes sort section
The sort is set up …

CurtisBridges 6 Light Poster

Here's a better explantion. Thanks!
This part"A" is already finished:

A). Create a menu with the following options, (1) Add, (2) Update, (3) Delete, (4) Sort, (5) Print, and (6) Quit.
Create an array of 10 strings up to 25 characters long and initialize each one to "none". Each item will represent a first name.
Create an array of function pointers to each of the above menu options. When the user selects an option call the appropriate function using this array.
Pass the string array to each of the functions as a parameter.
Use a bubble sort to sort the items.
Display the array when the user selects a menu item (except Sort, Print, and Quit) and then prompt the user for the nmnber (use the array subscript) of the item they want to operate on.
When deleting a name set it back to "none".
When deleting a name first confirm that the user wants to continue with the delete.

This is part"B" which has been added:
B). //I need to modify this code by changing the(existing) sort function to make it recursive
//and add a recursive binary search that prompts the user to enter a search item.
//I have added some code for the search, which I will mark with
// :?: commented out on previous line. Please help finsh with recursion. I'm lost.
//:mrgreen: denotes sort section
The sort is set up …

CurtisBridges 6 Light Poster

//I need to modify this code by changing the sort function to make it recursive
//and add a recursive binary search that prompts the user to enter a search item.
//I have added some code for the search, which I will mark with
// :mrgreen: commented out on previous line. Please help finsh with recursion. I'm lost.

#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<fstream>
#include<conio.h>
 
usingnamespace std;

char ProgramName[] = "Project 1.cpp"; // Used to hold the program name
int Option, *oPtr = &Option;
constint ARRAY_SIZE = 10;
char fname[ARRAY_SIZE][25]={"none","none","none","none",
"none","none","none","none","none","none"};
void StartUp(void);
void WrapUp(void);
void call(void (*)(void));
void Menu(char [ARRAY_SIZE][25]);
void Add(char [ARRAY_SIZE][25]);
void Update(char [ARRAY_SIZE][25]);
void Delete(char [ARRAY_SIZE][25]);
void Sort(char [ARRAY_SIZE][25]);
void Print(char [ARRAY_SIZE][25]);
void Printarr(char [ARRAY_SIZE][25]);
void Quit(char [ARRAY_SIZE][25]);
//:mrgreen: 
void Search(char [ARRAY_SIZE][25]);

int main (void)
{
StartUp();
system("cls");
Menu(fname);
return 0;
} // End of function main
 
 
void StartUp(void){
} // End of function StartUp
 
void call(void (*opt)(char arr[ARRAY_SIZE][25]))
{
(*opt)(fname);
}
 
 
void Menu(char arr[ARRAY_SIZE][25])
{
void (*f[6])(char arr[ARRAY_SIZE][25]) = {Add, Update, Delete, Sort, Printarr, Quit};
do
{
system("cls");
cout << "\t\t Menu"
<< "\n\t1. Add"
<< "\n\t2. Update"
<< "\n\t3. Delete"
<< "\n\t4. Sort"
<< "\n\t5. Print"
<< "\n\t6. Quit"
//:mrgreen: 
<< "\n7. Search"
<< "\n\n\tChoose and Option: ";
cin >> Option;
//:mrgreen: //6-7
if(Option < 1 || Option > 7)
{
cout << "\nPlease re-enter your selection." << endl;
 
_getch();
}
//:mrgreen: //6-7
} while(Option <1 || Option > 7);
call(f[Option-1]);
}
 
void Add(char arr[ARRAY_SIZE][25])
{
int Subscript = 0;
system("cls");
cout …
CurtisBridges 6 Light Poster

#13 [IMG]http://www.gidforums.com/images/buttons/reputation.gif[/IMG]
[IMG]http://www.gidforums.com/images/statusicon/post_old.gif[/IMG] 10-allican57@yahoo [IMG]http://www.gidforums.com/images/statusicon/user_online.gif[/IMG] vbmenu_register("postmenu_52405", true);
New Member
[IMG]http://www.gidforums.com/images/gid/ranks/rank1_5.gif[/IMG][IMG]http://www.gidforums.com/images/gid/ranks/rank1_5.gif[/IMG]
Join Date: Sep 2006
Posts: 21
[IMG]http://www.gidforums.com/images/reputation/reputation_pos.gif[/IMG]


Nov-2006, 15:17

I need to modify this code by changing the sort function to make it recursive and add a recursive binary search that prompts the user to enter a search item.I have added some code for the search, which I will mark with// [IMG]http://www.gidforums.com/images/gid/smilies/silly_hair.gif[/IMG]commented out on previous line. Please help finsh with recursion. I'm lost.
Code:
// ***********************************************************************// The include section// ***********************************************************************#include <iostream>#include <iomanip>#include <cstdlib>#include <ctime>#include <fstream>#include <conio.h>// ***********************************************************************// The namespace section// ***********************************************************************using namespace std;// ***********************************************************************// The global variable declaration section// ***********************************************************************char ProgramName[] = "Project 1.cpp"; // Used to hold the program nameint Option, *oPtr = &Option;const int ARRAY_SIZE = 10;char fname[ARRAY_SIZE][25]={"none","none","none","none", "none","none","none","none","none","none"};// ***********************************************************************// The function prototype section// ***********************************************************************void StartUp(void);void WrapUp(void);void call(void (*)(void));void Menu(char [ARRAY_SIZE][25]);void Add(char [ARRAY_SIZE][25]);void Update(char [ARRAY_SIZE][25]);void Delete(char [ARRAY_SIZE][25]);void Sort(char [ARRAY_SIZE][25]);void Print(char [ARRAY_SIZE][25]);void Printarr(char [ARRAY_SIZE][25]);void Quit(char [ARRAY_SIZE][25]);//:[IMG]http://www.gidforums.com/images/gid/smilies/silly_hair.gif[/IMG]: void Search(char [ARRAY_SIZE][25]);// ***********************************************************************// main// This is the entry point for this program. It controls// the flow of execution.// ***********************************************************************int main (void){ StartUp(); system("cls"); Menu(fname); return 0;} // End of function main// ***********************************************************************// StartUp// Currently this is an empty module or stub. It will be used to// perform any needed initialization.// ***********************************************************************void StartUp(void){} // End of function StartUp// ***********************************************************************// The Call function. This function is used to call the …

CurtisBridges 6 Light Poster

Nuts I'll be soon. I still cant get this to run.It keeps telling me cannot convert from const and I cant find where I declared a constant. Help Please!

#include <iostream>
#include <iomanip>
#include <conio.h>
 
using namespace std;
void call(void (*));
void Menu(char [11][25]);
void Add(char [11][25]);
void Update(char [11][25]);
void Delete(char [11][25]);
void Sort(char [11][25]);
void Print(char [11][25]);
void Printarr(char [11][25]);
void Quit(char [11][25]);
 
char Option, *oPtr = &Option;
char ArraySize =[11][25];
char fname[11][25]={"none","none","none","none",
"none","none","none","none","none","none"};
int main()
{

system("cls");
Menu(fname);
return 0;
}
void call(void (*opt)(char arr[11][25]))
{
(*opt)(fname);
}
void Menu(char arr[11][25])
{
void (*f[6])(char arr[11][25]) = {Add, Update, Delete, Sort, Printarr, Quit};
cout << "\t Menu"
<< "\n1. Add"
<< "\n2. Update"
<< "\n3. Delete"
<< "\n4. Sort"
<< "\n5. Print"
<< "\n6. Quit" 
<< "\n\nChoose and Option: ";
cin >> Option;
call(f[Option-1]);
}
void Add(char arr[11][25])
{
int Subscript = 0;
system("cls");
cout << "\t Adding Name Page\n\n";
Print(arr);
cout << "\n Which element do you want to add a name to (0 - 9): ";
cin >> Subscript;
if (Subscript < 0 || Subscript > 9)
{
cout << "\nSorry Invalid Selection Hit Enter to Return to the Main Menu\n";
system("pause");
system("cls");
Menu(fname);
}
else
{
if(strcmp(arr[Subscript], "none")== 0)
{
cout << "\nEnter a name: ";
cin >> arr[Subscript];
system("cls");
Menu(fname);
}
else
{
cout << "A name is already in this array. If you want"
<< "\nto update please go back to the Main Menu and "
<< "\nchoose the update option." << …
CurtisBridges 6 Light Poster

Not sure if this is posted in the correct forum!

Good Morning,
I am confined to a wheelchair and only have partial use of left hand and arm making it extremely slow and difficult to type. I am wanting to reassign the function keys(which I never use)to output the same phrase again and again. Kind of like office clipboard with no need to copy each time. Is this possible, and if so, how would I do it ? Curt Bridges allican57@yahoo.com

PS: By Wolfpack
User OS: Windows XP.

CurtisBridges 6 Light Poster

Thought I had this going, but I guess not. Would you look it over and get me headed in the right direction please.

Need help creating this to these instructions, mainly with the part where I call an existing files that has already been created and saved in Notepad as attached.(File one and File two). Below are the directions and some code. I think you will be able to tell what I’m trying to do, Thanks

Requirements:
Create a program to output the following. Make sure it is exact (except for the commission and percentage values):
Commissions calculated using a 0.07 value.
Sales Name Commission

See attachments(2)

This will be accomplished using the following:
1. Read the sales and name values from two input files.
2. Create an array of names and sales amounts (5 total).
3. Determine the commission by randomly generating a percentage number between .05 and. 10. Calculate the commission by multiplying this value times the sales amount.
4. Sort the file by name before printing.
5. Print the file to a third output file. The only thing that should show on the screen is the successful message.
6. Main should have no logic other than calling other functions. All actions should be done in functions (print, read files, sort).

#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
using namespace std;
char arrSales[7];
char arrNames[5][16];
 
const int ARRAY_SIZE = 5;
void PrintArray(char[ARRAY_SIZE][25], char …
CurtisBridges 6 Light Poster

We got it! Thanks for your help!

CurtisBridges 6 Light Poster

still can't read files. Next step please.

CurtisBridges 6 Light Poster

I had it declared as char originally and thought that was the problem so I changed it to double and that didn't fix it and forgot to change it back. good catch


why are those double and int arrays 2-dimensional??? Arrays must have a name. There are a couple ways you can to it. Leave the array size unspecified and pass the size as another parameter, as in your original attemp.

void PrintArray(double array[], int array_size);
void BubbleSort(double array[], int array_size);
void GetNames(double array[], int array_size);

or just not pass the size as a separate parameter, like this

void PrintArray(double array[ARRAY_SIZE]);
void BubbleSort(double array[ARRAY_SIZE]);
void GetNames(double array[ARRAY_SIZE]);

Isn't the array passed to GetNames() supposed to be an array of strings? Names normally are not arrays of doubles

void GetNames(char array[ARRAY_SIZE][25]);
CurtisBridges 6 Light Poster

1: #include <iostream.h>2:3: float Convert(float);4: int main()5: {6: float TempFer;7: float TempCel;8:9: cout << "Please enter the temperature in Fahrenheit: ";10: cin >> TempFer;11: TempCel = Convert(TempFer);12: cout << "\nHere's the temperature in Celsius: ";13: cout << TempCel << endl;14: }15:16: float Convert(float Fer)17: {18: float Cel;19: Cel = ((Fer - 32) * 5) / 9;20: return Cel;21: }You should get the same
I don't know, maybe this will help

CurtisBridges 6 Light Poster

Need help creating this to these instructions, mainly with the part where I call an existing files that has already been created and saved in Notepad as attached.(File one and File two). Below are the directions and some code. I think you will be able to tell what I’m trying to do, Thanks

Requirements:
Create a program to output the following. Make sure it is exact (except for the commission and percentage values):
Commissions calculated using a 0.07 value.
Sales Name Commission

See attachments(2)

This will be accomplished using the following:
1. Read the sales and name values from two input files.
2. Create an array of names and sales amounts (5 total).
3. Determine the commission by randomly generating a percentage number between .05 and. 10. Calculate the commission by multiplying this value times the sales amount.
4. Sort the file by name before printing.
5. Print the file to a third output file. The only thing that should show on the screen is the successful message.
6. Main should have no logic other than calling other functions. All actions should be done in functions (print, read files, sort).

Code:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>

using namespace std;

ofstream OutFile("A:\\File one.out");
ifstream InFile("A:\\File one.in");

const int ARRAY_SIZE = 5;

void PrintArray(double[ARRAY_SIZE][25], int ARRAY_SIZE);
void BubbleSort(double[ARRAY_SIZE][25], int ARRAY_SIZE);
void GetNames(double[ARRAY_SIZE][25], int …

CurtisBridges 6 Light Poster


so far . I'm just missing something,but don't know what. Thanks

{ char array [10] = {'a','b','c','d','e','f','g','h','i','j'};
cout << "The value is: " << array[3] << "." << endl;

for (char array[10] = 8; array < 9; array[10] 5 ==)
array[10] = 8;

CurtisBridges 6 Light Poster

Well, that's an pretty simple asignment and if you have payed attention in class/course will you be able to figure it out. If you need any help with it then ask it here again!

Having trouble with step "c" can you help me out?

c) Initialize each of the 5 elements of single-subscripted integer array g to 8.

CurtisBridges 6 Light Poster

Thanks. All help is appreciated. This stuff is just not sinking in. I have scanned the directions out of the book,if you have any other ideas. Thanks again.

4.8
.
Write C++ statements to accomplish each of the following:
a) Display the value of the seventh element of character array f.
b) Input a value into element 4 of single-subscripted floating-point array b.
c) Initialize each of the 5 elements of single-subscripted integer array g to 8.
d) Total and print the elements of floating-point array c of 100 elements.
e) Copy array a into the first portion of array b. Assume double a[ 11], b[ 34];
f) Determine and print the smallest and largest values contained in 99-element floating-point array w.

CurtisBridges 6 Light Poster

Hi everyone. Iam a beginning C++ student having trouble with a simple one column char. aray. what I'm trying to do is : display the value of the seventh element of chaacter array f. Wich shoud b 6 if a=0. Please help. Below is my code, so far:
[
#include <iostream>
#include <iomanip>

using namespace std;

int value;
int main()
{
const char(10);
char chABCD[10] = { 'a', 'b', 'c', 'd', 'e', 'f' };
for ( int a = 0; a < 10; a++)
a=(0);
cout << value('f') << endl;]

CurtisBridges 6 Light Poster

I have a group project of designing the old board game "CLUE" in my C++ class that can be played by 1 person against the computer. If someone would help me get started it would help a bunch. I think this could be a neat project, but have no clue as to how to get it started.

CurtisBridges 6 Light Poster

we have not covered the bool functions in class yet. This was something that was suggested to me, I think there is a way to use the function " counter" but am not sure. Any ideas would help. It compiles fine. I'm just looking for a different way of coding it.

CurtisBridges 6 Light Poster

Would somebody chck this code please. I am a struggling C++ student and need all the help I can get. Thanks, Curt

Here are the directions:
create a function that check's the number, put's out whether
it's odd or even and adds it to the total variable

#include"stdafx.h"
#include<iostream>
 
usingnamespace std;
//declare the variable's
int total;
int number_buffer = 1;
 
bool checker(int number)
{
if(number == 0){return false;}
if(number%2)
{
cout << number << " is odd" << endl;
} else {
cout << number << " is even" << endl;
}
total += number;
}
int main()
{
//request user input
cin >> number_buffer;
//continue to ask input until 0 is entered, 
//if 0 is entered does checker return's false, else true.
while(checker(number_buffer)){cin >> number_buffer;}
//show the total
cout << "Total: " << total;
return 0;
}
CurtisBridges 6 Light Poster

He's posting non-spam in the C/C++ forum to get nice green dots beside his name. :cheesy:

It looks like you tried to post an image and it didn't quite work. Try clicking "Attachments" in the Advanced message window. Oh and try to explain the problem too, like what you tried and what happened.

Sorry meant to right-click. Curt

CurtisBridges 6 Light Poster

This is really a school example of how post shouldn't look like!

Sorry, first timer. I meant to right-click. Curt

CurtisBridges 6 Light Poster

Thank You.Curt

CurtisBridges 6 Light Poster

I got stumped can someone please help ?
I’m working on this home work assignment and can’t get past this point.

Here is how far I’ve got:

#include <iostream>
#include <iomanip>
 
using namespace std;
 
using std::cout;
using std::cin;
using std::endl;
 
int main()
{
 
int numbers,to,Enter,odd,even;
int integer,positive,a;
 
 
 
 
cout << " Enter a positive integer(0 to quit):";//0
 
cout << " Enter a positive integer(0 to quit):";//0
cin >> integer >>;
cout << "The total of the odd numbers entered is:";//0
cout << "The total of the even numbers entered is:";//0
 
 
cin >> Enter a positive integer(0 to quit):1;
cout << " 1 is odd";
cin >> Enter a positive integer(0 to quit):2;
cout << " 2 is even";
cin >> Enter a positive integer(0 to quit):3;
cout << " 3 is odd";
cin >> Enter a positive integer(0 to quit):4;
cout << " 4 is even";
cin >> Enter a positive integer(0 to quit):0<< endl
 
 
return 0;
 
 
}

And there is an attachment of the assignment:

CurtisBridges 6 Light Poster

[IMG]file:///C:/Documents%20and%20Settings/Curtis%20Bridges/My%20Documents/My%20Pictures/Dinosaurs/scan.gif[/IMG]

CurtisBridges 6 Light Poster

I would like to introduce and tell you a little about myself. My name is "Curtis Bridges" but I like and have always been called "Curt". I'm 49 years old. I have been happily married for 31 years. I am very proud to be the "father" of an architect and a contractor. I must brag about a 5-year-old "grandson" and a 2- year-old "granddaughter", that keeps me "on my toes".
On March 17, 1999, while working as a superintendent for a large underground utility contractor out of Denver CO (Texas Division) I suffered a "Giant Basilar Aneurysm" requiring emergency surgery and leaving me paralyzed. Coming out of surgery and after a month in "ICU" the only movement I had was the ability to blink my left eye.
Originally being from Jefferson City, MO and having two sons and many relatives here, I was flown back to MO, by an air ambulance for eight months of extensive "inpatient therapy" and one year of "outpatient therapy" where I regained partial use of my left hand and learned to talk again (though not very well). So here I sit, today confined to a wheelchair. I was fortunate to be left without any "memory loss".
My voice is very soft and hard to understand therefore I speak through an electronic speech enhancer connected to speakers on my wheelchair.
After the past several years of being paralyzed, I have noticed that if you don't keep up the "pace" with "current events …

Anonymusius commented: Much strength +1