模块化程序错误

编程入门 行业动态 更新时间:2024-10-23 21:27:35
本文介绍了模块化程序错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好我已经完成了我的程序,但它无法编译。我检查了花括号,它们都是对齐的。但是,我收到最后一个大括号的错误(类型或命名空间定义,或预期的文件结束)。我确信这与模块有关,但此时我不知道那可能是什么。任何有关这方面的帮助将不胜感激。谢谢

Hello I have most completed my program and yet it will not compile. I have checked out the curly braces and they are all aligned. However, I am receiving an error from the very last curly brace stating (Type or namespace definition, or end of file expected). I am sure that this has something to do with the modules, but at this point I don't know what that might be. Any help with this would be greatly appreciated. Thanks

namespace VS_Sand_Box { class Program { static void Main(string[] args) { //Enter Varibales string customerName, customerState; int unitAmount; double unitPrice, totalPrice, totalTax; //Gather user input Console.Write("Enter the customer's name: "); customerName = Console.ReadLine(); Console.Write("Enter the location of transaction i.e.(NJ, FL, or NY): "); customerState = Console.ReadLine(); Console.Write("Enter the amount of units being purchased: "); unitAmount = Int32.Parse(Console.ReadLine()); Console.Write("Enter the price per unit: "); unitPrice = Double.Parse(Console.ReadLine()); //Jump to Module 1 totalPrice = computeTotal(unitAmount, unitPrice); //Jump to Module 2 totalTax = computeTax(totalPrice, customerState); //Continue with output Console.WriteLine( "\n\nThe total sales for" + customerName + " are " + totalPrice.ToString("C2")); Console.Write("The tax amount is " + totalTax.ToString("C2")); Console.WriteLine( "\nThe total with tax is $" +(totalTax + totalPrice)); Console.ReadLine(); } //Module 1 public static double computeTotal (int qty, double price) { return (qty * price); } //Module 2 public static double computeTax (double totalPrices, string customerState) { if (customerState == "NJ") return totalPrices * .07; else if (customerState == "FL") return totalPrices * .04; else if (customerState == "NY") return totalPrices * .06; else return 0; } } } //Error!!! Type namespace definition, or end-of-file expecedted Error!!! }

推荐答案

+(totalTax + totalPrice)); Console.ReadLine(); } // 第1单元 public static double computeTotal( int qty, double 价格) { return (qty * price); } // 模块2 public static double computeTax( double totalPrices,串 customerState) { if (customerState == NJ) return totalPrices *。 07 ; else if (customerState == FL) return totalPrices *。 04 ; else if (customerState == NY) return totalPrices *。 06 ; else return 0 ; } } } // 错误!键入命名空间定义,或者文件结束时出错!!! } " +(totalTax + totalPrice)); Console.ReadLine(); } //Module 1 public static double computeTotal (int qty, double price) { return (qty * price); } //Module 2 public static double computeTax (double totalPrices, string customerState) { if (customerState == "NJ") return totalPrices * .07; else if (customerState == "FL") return totalPrices * .04; else if (customerState == "NY") return totalPrices * .06; else return 0; } } } //Error!!! Type namespace definition, or end-of-file expecedted Error!!! }

<pre lang="text"><pre lang="cs">namespace VS_Sand_Box { class Program { static void Main(string[] args) { { //Enter Varibales string customerName, customerState; int unitAmount; double unitPrice, totalPrice, totalTax; //Gather user input Console.Write("Enter the customer's name: "); customerName = Console.ReadLine(); Console.Write("Enter the location of transaction i.e.(NJ, FL, or NY): "); customerState = Console.ReadLine(); Console.Write("Enter the amount of units being purchased: "); unitAmount = Int32.Parse(Console.ReadLine()); Console.Write("Enter the price per unit: "); unitPrice = Double.Parse(Console.ReadLine()); //Jump to Module 1 totalPrice = computeTotal(unitAmount, unitPrice); //Jump to Module 2 totalTax = computeTax(totalPrice, customerState); //Continue with output Console.WriteLine("\n\nThe total sales for " + customerName + " are " + totalPrice.ToString("C2")); Console.Write("The tax amount is " + totalTax.ToString("C2")); Console.WriteLine("\nThe total with tax is

+(totalTax + totalPrice)); Console.ReadLine(); } } // 第1单元 public static double computeTotal ( int qty, double price) { 返回(数量*价格); } // 模块2 public static double computeTax( double totalPrices, string customerState) { if (customerState == NJ) return totalPrices *。 07 ; else if (customerState == FL) return totalPrices *。 04 ; else if (customerState == NY) return totalPrices *。 06 ; else return 0 ; } } } " + (totalTax + totalPrice)); Console.ReadLine(); } } //Module 1 public static double computeTotal (int qty, double price) { return (qty * price); } //Module 2 public static double computeTax (double totalPrices, string customerState) { if (customerState == "NJ") return totalPrices * .07; else if (customerState == "FL") return totalPrices * .04; else if (customerState == "NY") return totalPrices * .06; else return 0; } } }

更多推荐

模块化程序错误

本文发布于:2023-11-15 04:04:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1590986.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!