新手请教scanf()自动跳过的问题
先上代码
#include "stdio.h"#include "stdlib.h"#include "math.h"double teacher_total(double _amount){ double total; printf("Total purchases $%6.2lf\n", _amount); if(_amount >= 100) { total = _amount * (1 - 0.12); printf("Teacher's discount (12%%) %6.2lf\n", _amount * 0.12); printf("Discounted total $%6.2lf\n", total); } else{ total = _amount * (1 - 0.10); printf("Teacher's discount (10%%) %6.2lf\n", _amount * 0.10); printf("Discounted total $%6.2lf\n", total); } printf("Sales tax (5%%) %6.2lf\n", total * 0.05); printf("Total $%6.2lf\n", total * 1.05);}double non_teacher(double _amount){ printf("Total purchases $%6.2lf\n", _amount); printf("Sales tax (5%%) %6.2lf\n", _amount * 0.05); printf("Total $%6.2lf\n", _amount * 1.05);}int main(){ double amount; char is_teacher; printf("KEITH'S SHEET MUSIC CALCULATOR\n"); printf("Please enter the total amount for purchase ($):\n"); scanf("%lf", &amount); printf("Are you a music teacher? "); scanf("%c", &is_teacher); printf("\n"); printf("RECEIPT\n"); if(is_teacher == 'Y') { teacher_total(amount); } else{ non_teacher(amount); } system("PAUSE"); return 0; }