C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 17th, 2010, 04:23 PM
Ramenen Ramenen is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2010
Posts: 1 Ramenen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 25 sec
Reputation Power: 0
Thumbs up C++ help

This is what i need to do.

*NO PASS BY REFERENCE CAN BE USED, ONLY VALUES*
Write a C program to aid the Michigan Bookstore in estimating its business for next quarter. Experience has shown that sales depend on whether a book is required or suggested, and on whether or not it has been used before. A new, required book will sell to 90% (.90) of expected enrollment, but if it has been used before only 65% of the expected enrollment will buy it. Similarly, 40% of the expected enrollment will buy a newly suggested book, but only 20% will purchase a previously suggested book.

INPUT
Your program is to prompt the user for:
- the book's 10 digit ISBN number as 10 separate characters
- the list price per copy
- the expected class enrollment
- code of 'R'for required text or code of 'S' for suggested text
- code of 'N' for a new text or code of 'O' for a text that has been used the previous quarter

CALCULATE
Calculate the number of copies needed and the profit if the store pays 80% of list (use global define for this). Use one to function to calculate number of books, one function to calculate the profit, and one function to output.

OUTPUT A sample run might look like this:

Enter book number: 0755798652
Enter price per copy: 34.98
Enter expected class enrollment: 31
Enter 'R' if required or 'S' if suggested: r
Enter 'N' if new or 'O' if not a new text: O

ISBN: 0-75-579865-2
Copies Needed: 20
Profit: $ 146.92


This is what i have


Code:
#include<stdio.h>

//declare functions
void inputData(char, char, char, char, char,
			   char, char, char, char, char,
			   float, int, char, char);
void output(char, char, char, char, char, 
			char, char, char, char, char,
			int, float);
int main(void)
{
	//declare variables
	char n_1;
	char n_2;
	char n_3;
	char n_4;
	char n_5;
	char n_6;
	char n_7;
	char n_8;
	char n_9;
	char n_10;
	float price;
	int enrollment;
	char R_S;
	char N_O;
	int copies;
	float profit;



	//Input
	n_1=inputData();
	n_2=inputData();
	n_3=inputData();
	n_4=inputData();
	n_5=inputData();
	n_6=inputData();
	n_7=inputData();
	n_8=inputData();
	n_9=inputData();
	n_10=inputData();
	inputData(price, enrollment);
	R_S=inputData();
	N_O=inputData();

	//Calculations

	//Output
	output(n_1, n_2, n_3, n_4, n_5, n_6, n_7,
			n_8, n_9, n_10, copies, profit);

	return 0;
}///End Main///////////////////////////////

void inputData(char n_1, char n_2, char n_3, char n_4, char n_5, 
			   char n_6, char n_7, char n_8, char n_9, char n_10,
			   float price, int enrollment, char R_S, char N_O)
{	
	//Prompt user for necessary information
	printf("Enter book number: ");
	scanf(" %c %c %c %c %c %c %c %c %c %c", 
		&n_1, &n_2, &n_3, &n_4, &n_5, &n_6, &n_7, &n_8, &n_9, &n_10);
	
	printf("Enter price per copy: ");
	scanf("%.2f", &price);

	printf("Enter expected class enrollment: ");
	scanf("%f", &enrollment);
	
	printf("Enter 'R' if required or 'S' if suggested: ");
	scanf(" %c", &R_S);
	
	printf("Enter 'N' if new or 'O' if not a new text: ");
	scanf(" %c", &N_O);
	
	return ;
}

void output(char n_1, char n_2, char n_3, char n_4, char n_5, 
			char n_6, char n_7, char n_8, char n_9, char n_10,
			int copies, float profit)
{
	
	
	printf("ISBN: %c - %c %c - %c %c %c %c %c %c - %c", 
		&n_1, &n_2, &n_3, &n_4, &n_5, &n_6, &n_7, &n_8, &n_9, &n_10);
	printf("Copies Needed: %d", &copies);
	printf("Profit: %f", &profit);

	return;

}


What am i missing or need to add/fix? thanks in advanced

Reply With Quote
  #2  
Old February 18th, 2010, 03:24 AM
clifford's Avatar
clifford clifford is offline
Contributing User
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Aug 2003
Location: UK
Posts: 4,808 clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 17 h 42 m 14 sec
Reputation Power: 1800
Quote:
Originally Posted by Ramenen
- the book's 10 digit ISBN number as 10 separate characters
An array of 10 characters, is still 10 separate characters, and much simpler to handle.
Quote:
Originally Posted by Ramenen
What am i missing or need to add/fix? thanks in advanced
Test it against the specification and tell us what does not work - that is what is missing or needs fixing. Once you have figured that out, ask more specific questions if you remain stuck. Don't make us review/test your code unnecessarily.

Reply With Quote
  #3  
Old February 18th, 2010, 11:38 PM
pavun_cool pavun_cool is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2010
Posts: 3 pavun_cool User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 26 m 29 sec
Reputation Power: 0
Use Chracter Array instead of using 10 different character variables.

You can use Character array for storing 10 characters . You can access each character by its index easily. Why are you using 10 different character variables.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > C++ help

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap