Consider the program given below. Find all du-paths and identify those du-paths that are definition clear. Also
Question:
Consider the program given below. Find all du-paths and identify those du-paths that are definition clear. Also find all du-paths, all-uses and all-definitions and generate test cases for these paths.
/* Program to calculate total telephone bill amount to be paid by an customer*/
#include
#include
1. void main()
2. {
3. int custnum,numcalls,valid=0;
4. float netamount;
5. clrscr();
6. printf("Enter customer number & number of calls:");
7. scanf("%d %d",&custnum,&numcalls);
8. if(custnum>10&&custnum<20000){
9. valid=1;
10. if(numcalls<0){
11. valid=-1;
12. }
13. }
14. if(valid==1){
15. if(numcalls<76){
16. netamount=500;
17. }
18. else if(numcalls>75&&numcalls<201){
19. netamount=500+0.80*(numcalls-75);
20. }
21. else if(numcalls>200&&numcalls<501){
22. netamount=500+1.00*(numcalls-200);
23. }
24. else{
25. netamount=500+1.20*(numcalls-500);
26. }
27. printf("Customer number: %d\t Total Charges:%.3f",custnum,netamount);
28. }
29. else if(valid==0){
30. printf("Invalid customer number");
31. }
32. else{
33. printf("Invalid number of calls");
34. }
35. getch();
36. }
Step by Step Answer:
Flexible, Reliable Software Using Patterns And Agile Development
ISBN: 9781439882726
1st Edition
Authors: Henrik B Christensen