Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

I am lost - simple calculations

Posted on 2001-06-18
6
Medium Priority
?
242 Views
Last Modified: 2010-04-15
I hav been trying to do this all nite, The program itself runs ok, But when i enter  the over time hours it does not give me an amount. it returns 0.00.
What have i done wrong towars the end of this program as it is only the overtime pay bit that doesnt work.
#include <stdio.h>

void main()
{
  float hours,pounds,amount;    
     
     printf("\n Please enter the amount of standard hours you worked ");
     scanf("%f", &hours);
     
     printf("\n Enter Hourly rate ");
      scanf("%f", &pounds);    
           
     amount = (float)hours*(float)pounds;
      printf("\n Wages for week excluding Over time %.2f pounds \n");
     
{
 float ovrtimrat;
      ovrtimrat = (float)1.25*(float)pounds;
      printf("\n Over time Rate is %.2f pounds \n");
     
{
  float ovmony,hoursa,ovrtimrat;
      printf("\n Enter hours of overtime worked ");
      scanf("%f", &hoursa);
 
     ovmony = (float)ovrtimrat*(float)hoursa;          
      printf("\n Overtime pay is %.2f pounds");

}
}
}

0
Comment
Question by:pnorris98
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 16

Accepted Solution

by:
imladris earned 800 total points
ID: 6203656
The printf lines where you're attempting to print out a calculated amount, must have a relevant variable passed in:


     printf("\n Wages for week excluding Over time %.2f pounds \n",amount);
   
     printf("\n Over time Rate is %.2f pounds \n",ovrtimrat);
     
     printf("\n Overtime pay is %.2f pounds",ovmony);

0
 
LVL 5

Expert Comment

by:marecs
ID: 6203664
#include <stdio.h>

void main()
{                                                                              
    float hours,pounds,amount;                                                  
    printf("\n Please enter the amount of standard hours you worked ");        
    scanf("%f", &hours);                                                        
    printf("\n Enter Hourly rate ");                                            
    scanf("%f", &pounds);                                                      
    amount = (float)hours*(float)pounds;                                        
    printf("\n Wages for week excluding Over time %.2f pounds \n", amount);    
                                                                               
    {                                                                          
        float ovrtimrat;                                                        
        ovrtimrat = (float)1.25*(float)pounds;                                  
        printf("\n Over time Rate is %.2f pounds \n", ovrtimrat);              
                                                                               
        {                                                                      
            float ovmony,hoursa;                                                
            printf("\n Enter hours of overtime worked ");                      
            scanf("%f", &hoursa);                                              
            ovmony = (float)ovrtimrat*(float)hoursa;                            
            printf("\n Overtime pay is %.2f pounds\n", ovmony);                
        }                                                                      
    }                                                                          
}                                                                              
0
 
LVL 5

Expert Comment

by:marecs
ID: 6203665
Ignore my comment. It was just 2 minutes too late ;-)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:imladris
ID: 6206794
Did that answer the question pnorris? If so, it is now time to grade the answer.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6402286
This question was LOCKED with a PROPOSED ANSWER and awaits your decision today.  Once a question is LOCKED with a Proposed Answer, few new experts will step in to help on that question, since the assumption is, you've been helped.  If the Proposed Answer helped you, please accept it and award that expert.  If it did not help you, please reject it and add comments as to status and what else is needed.
 
If you wish to award multiple experts, just comment here with detail, I'll respond as soon as possible.  As it stands today, you asked the question, got help and not one expert was awarded for the contribution(s) made.  Your response is needed.  I'll monitor through month end, and if you've not returned to complete this, we'll need to decide.  Expert input is welcome (as always) to determine the outcome here if the Asker does not respond.
 
Your response in finalizing this (and ALL) your question(s) is appreciated.
 
Moondancer
Community Support Moderator @ Experts Exchange

0
 

Author Comment

by:pnorris98
ID: 6524265
dam,
Hey Im sorry guys I sooooo forgot about this.
I need to take more care with my questions,

Sorry again guys
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question